Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: CGI::Application, inheritance trees, and 'the right way'

by geektron (Curate)
on Nov 02, 2004 at 07:36 UTC ( [id://404521]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI::Application, inheritance trees, and 'the right way'
in thread CGI::Application, inheritance trees, and 'the right way'

OK -- so i'm trying to get my head around this, and it's just confusing me.
  1. where is  $this coming from, and what is it supposed to reference?
  2. how does SiteManager dispatch sub-requests in this case? i can see that a new EventManager is instantiated, but when I tried it, i got an infinite loop
maybe a better explanation of what i'm doing (or trying to do) is a better idea ...

essentially, the admin side of this site has various management functions ( email editing, email sending, event calendar population ), and i'd like to keep on URL for the client so that he can just bookmark (or remember ) that and be done with it.

because each 'set' of admin functions does different things, i'm trying to break those out into modules so that what got called for what set of functions is easier to find.

i'm anticipating a menu (top or left, doesn't matter) where links like "manage email" and "manage events" will be, and those are the 'sets' of functions i'm using.

i can see the links going to other CGI scripts, but the only thing that saves me, i think, is the confusion of trying the 'dispatch tables' i'm working towards now ...

Replies are listed 'Best First'.
Re^3: CGI::Application, inheritance trees, and 'the right way'
by weierophinney (Pilgrim) on Nov 03, 2004 at 13:19 UTC

    $this was a typo; should have been $self.

    In the example, SiteManager isn't dispatching sub-requests; I should have used different names than those you'd given. I was considering the modules that SiteManager might load being not additional CGI::Application modules or modules that create output but API level things -- grabbing events for a calendar that needs to be displayed on every page, or a site navigation that needs to be custom generated on each page.

    You can still have a single page that your client can bookmark, but this might be more of a homepage with links to other applications. The applications would all inherit from SiteManager so that you get:

    • Centralized authentication
    • Centralized navigation
    • Sitewide template shell
    • etc.

    Another possibility would be to have an application that would dynamically instantiate and run() other CGI::Applications:

    package SiteManager; use base qw/CGI::Application/; use EventManager; use EmailManager; sub setup { $self = shift; $self->run_modes( 'events' => 'events', 'email' => 'email ); } sub events { $self = shift; # Initialize a params hash or grab it from a config file and t +hen... $events = new EventManager($params); $events->run(); } sub email { $self = shift; # Initialize a params hash or grab it from a config file and t +hen... $email = new EmailManager($params); $email->run(); }

    However, even with this example, it might not be a bad idea to have a base class that takes care of authentication, site template, etc.

Re^3: CGI::Application, inheritance trees, and 'the right way'
by saberworks (Curate) on Nov 02, 2004 at 18:19 UTC
    $this is probably a typo for $self - C++ & PHP use the name "this" rather than the perl way, which allows you to name it whatever you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://404521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-16 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found