|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Runmodes in separate modulesI am new to cgi-app (titanium) and am hoping someone can give me some help
on runmode Controller routines. I don't like the idea of having all of my controller runmode code in the base module. I will have dozens of runmodes. I would like to be able to separate my runmodes into logical modules, but I am not sure how to get that to work. This works: # dashboard runmode in MyApp.pm MyApp.pl: #!/usr/local/bin/perl use strict; use lib 'lib'; use MyApp; my $webapp = ReliaWeb->new(); $webapp->run(); lib/MyApp.pm: package MyApp.pm; use base 'Titanium'; use CGI::Application::Plugin::ActionDispatch; sub setup { my ($self) = @_; return; } sub display_dashboard : Path('dashboard/') { return qq{<html><body>Dashboard</body></html>}; #Testing runmode } ############################################################## Here is what I want to do instead but does not work this way: # (dashboard runmode in its own module) MyApp.pl: [no change] lib/MyApp.pm: package MyApp.pm; use base 'Titanium'; use MyApp::Admin::Dashboard; sub setup { my ($self) = @_; return; } lib/MyApp/Admin/Dashboard.pm: package Dashboard: use base 'MyApp'; use CGI::Application::Plugin::ActionDispatch; sub display_dashboard : Path('dashboard/') { return qq{<html><body>Dashboard</body></html>}; #Testing runmode } ############################################################# Thanks in advance for any guidance you can provide. Victor ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Runmodes in separate modulesVictor Bruno wrote:
> sub display_dashboard : Path('dashboard/') That's catalyst style code. The way I achieve what you are talking about is to require in the relevant module based on the runmode name. That way if you are in Vanilla CGI you only load the modules you need for the current process. During the setup phase I check what modules are in a set folder and populate the runmode has based on that. Hope that makes sense... Lyle ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
RE: Runmodes in separate modules>> sub display_dashboard : Path('dashboard/')
>That's catalyst style code. The way I achieve what you are talking about >is to require in the relevant module based on the runmode name. That way >if you are in Vanilla CGI you only load the modules you need for the >current process. During the setup phase I check what modules are in a >set folder and populate the runmode has based on that. After more searching, it looks like C::A::Dispatch is going to fit my needs best. It allows me to have my runmodes organized in separate logical modules and link to them dynamically from the url. Here is what I ended up with: ########################################################################### myApp_Dispatch.pl: use lib 'lib'; use CGI::Application::Dispatch; CGI::Application::Dispatch->dispatch( prefix => 'MyApp::Controller' ); lib/MyApp.pm: package MyApp.pm; use base 'Titanium'; sub setup { my ($self) = @_; return; } 1; lib/MyApp/Controller/Admin/Dashboard.pm: package MyApp::Controller::Admin::Dashboard; use base 'MyApp'; sub setup { my ($self) = @_; $self->run_modes( [qw/ display_dashboard /] ); } sub display_dashboard { return qq{<html><body>Dashboard in a mod</body></html>}; } ########################################################################## Then my url can look like: http://dev1/MyApp/myApp_Dispatch.pl/admin_dashboard/display_dashboard/ ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
RE: Runmodes in separate modulesHi Victor
On Sun, 2009-09-06 at 17:53 -0500, Victor Bruno wrote: > After more searching, it looks like C::A::Dispatch is going to fit my needs > best. It allows me to have my runmodes organized in separate logical modules > and link to them dynamically from the url. Yep. C::A::Dispatch is a marvellous module. > Then my url can look like: > http://dev1/MyApp/myApp_Dispatch.pl/admin_dashboard/display_dashboard/ Still quite long. Have you considered /dashboard/display? And for admins, /dashboard/admin/display? -- Ron Savage ron@... http://savage.net.au/index.html ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
| Free embeddable forum powered by Nabble | Forum Help |