Structuring Dancer Application
Hi to all, I've programmed ten years ago a CGI web page for our company. We've decided to upgrade it, to a moderm framework. I'm starting to develop it with Dancer. Makes easy a lot of things that were dificult. I'm concerned on how we can structure the application. I'd like to divide my application in several files, but I haven't found in the documentation the mode to call diferent packages or modules depending on the route. Best regards, R. Fontardion
Your application .pl script can include a bunch of different Dancer application modules. Each application module can set a "prefix" which gets prepended to all the routes in that module. I have: Web::Root which has prefix undef Web::Forum which has prefix /forums http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE... On Thu, Mar 24, 2011 at 1:44 PM, Forgoselo Fontardion <fontardion@gmail.com> wrote:
Hi to all, I've programmed ten years ago a CGI web page for our company. We've decided to upgrade it, to a moderm framework. I'm starting to develop it with Dancer. Makes easy a lot of things that were dificult. I'm concerned on how we can structure the application. I'd like to divide my application in several files, but I haven't found in the documentation the mode to call diferent packages or modules depending on the route.
Best regards, R. Fontardion _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hey guys, On Thu, Mar 24, 2011 at 10:49 PM, Brian E. Lozier <brian@massassi.com>wrote:
http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE...
Better use a more up-to-date version: http://search.cpan.org/perldoc?Dancer::Introduction S.
Hello, Thank you for answering my question. Maybe I didn't explain the question correctly.I want to be able to split the logic in diferent modules. In your example: "/" calls Web::Root, how do you call Web::Root from web.pm? "/forums" calls Web::Forum, how do you call Web::Forum from web.pm? Best regards, Fontardion 2011/3/25 sawyer x <xsawyerx@gmail.com>
Hey guys,
On Thu, Mar 24, 2011 at 10:49 PM, Brian E. Lozier <brian@massassi.com>wrote:
http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE...
Better use a more up-to-date version: http://search.cpan.org/perldoc?Dancer::Introduction
S.
This is the script I use to run it: #!/usr/local/bin/perl use Dancer; use Fan::Web::Root; use Fan::Web::Forum; dance(); This sets up an internal server at 0:5000 or 0.0.0.0:3000 or something depending on whether I'm using perl myscript.pl or plackup myscript.pl. I don't ever call those modules directly and I don't actually have a "Web.pm" -- I may be confusing the issue because I did not start from scaffolding, I started from scratch (you can can look at the mailing list history for my questions regarding that). On Fri, Mar 25, 2011 at 5:01 PM, Forgoselo Fontardion <fontardion@gmail.com> wrote:
Hello,
Thank you for answering my question.
Maybe I didn't explain the question correctly.I want to be able to split the logic in diferent modules. In your example: "/" calls Web::Root, how do you call Web::Root from web.pm? "/forums" calls Web::Forum, how do you call Web::Forum from web.pm?
Best regards, Fontardion
2011/3/25 sawyer x <xsawyerx@gmail.com>
Hey guys,
On Thu, Mar 24, 2011 at 10:49 PM, Brian E. Lozier <brian@massassi.com> wrote:
http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE...
Better use a more up-to-date version: http://search.cpan.org/perldoc?Dancer::Introduction
S.
On Fri, Mar 25, 2011 at 8:01 PM, Forgoselo Fontardion <fontardion@gmail.com> wrote:
Hello,
Thank you for answering my question.
Maybe I didn't explain the question correctly.I want to be able to split the logic in diferent modules. In your example: "/" calls Web::Root, how do you call Web::Root from web.pm? "/forums" calls Web::Forum, how do you call Web::Forum from web.pm?
=== web.pm === use Dancer ':syntax'; use Web::Root; get '/' => sub { Web::Root::foo() }; get '/forums' => sub { Web::Forum::bar() }; Is that what you want? -Naveed
Best regards, Fontardion
2011/3/25 sawyer x <xsawyerx@gmail.com>
Hey guys,
On Thu, Mar 24, 2011 at 10:49 PM, Brian E. Lozier <brian@massassi.com> wrote:
http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE...
Better use a more up-to-date version: http://search.cpan.org/perldoc?Dancer::Introduction
S.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Well : in libs, add web/root.pm and web/forum.pm in web/root.pm get '/' => sub { ... } in web/forum.pm get '/forum' => sub { ... } and include all of these to bin/app.pl use Web::Root; use Web::Forum; Hope can help :) Le 26 mars 2011 à 05:35, Naveed Massjouni a écrit :
On Fri, Mar 25, 2011 at 8:01 PM, Forgoselo Fontardion <fontardion@gmail.com> wrote:
Hello,
Thank you for answering my question.
Maybe I didn't explain the question correctly.I want to be able to split the logic in diferent modules. In your example: "/" calls Web::Root, how do you call Web::Root from web.pm? "/forums" calls Web::Forum, how do you call Web::Forum from web.pm?
=== web.pm === use Dancer ':syntax'; use Web::Root; get '/' => sub { Web::Root::foo() }; get '/forums' => sub { Web::Forum::bar() };
Is that what you want? -Naveed
Best regards, Fontardion
2011/3/25 sawyer x <xsawyerx@gmail.com>
Hey guys,
On Thu, Mar 24, 2011 at 10:49 PM, Brian E. Lozier <brian@massassi.com> wrote:
http://search.cpan.org/~sukria/Dancer-1.2005/lib/Dancer/Introduction.pod#PRE...
Better use a more up-to-date version: http://search.cpan.org/perldoc?Dancer::Introduction
S.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
participants (5)
-
Brian E. Lozier -
Forgoselo Fontardion -
Geistteufel -
Naveed Massjouni -
sawyer x