Is it possible to pass the 'session' hash to a subroutine and set it in there? This is something I did in Dancer2 for setting some sessions..
On Tue, Sep 10, 2013 at 4:16 PM, Hugues Max <[email protected]> wrote: > In fact a search a solution to DO NOT repeat in my code something like > > > my $PATHXLS = config->{'PATHXLS'}.session 'numclient' > for each route > > > for the moment > in: > get '/outils' => sub { > I add: my $PATHXLS = config->{'PATHXLS'}.session 'numclient' > > post '/outils' => sub { > I add: my $PATHXLS = config->{'PATHXLS'}.session 'numclient' > > if I have 10 sessions setting, I need to add 10 lines per route > etc... > what is the solution ? > > > > Le 10/09/2013 16:08, Stefan Hornburg (Racke) a écrit : > > On 09/10/2013 04:05 PM, Hugues Max wrote: >> >>> Please see my hook ( here numclient = 366 ) >>> >>> >>> hook 'before' => sub { >>> var numclient => session 'numclient'; >>> debug "session numclient ". session 'numclient';; >>> debug "vars in hook ".vars->{'numclient'}; >>> }; >>> >>> debug "vars out hook" . vars->{'numclient'}; >>> >>> >>> >>> and log >>> >>> [8425] debug @0.004796> [hit #1]session numclient 366 in >>> /home/faxexpert/DancerFx/lib/**fx/outils.pm l. 25 >>> [8425] debug @0.004964> [hit #1]vars in hook 366 in >>> /home/faxexpert/DancerFx/lib/**fx/outils.pm l. 26 >>> [8425] core @0.005126> [hit #1]entering before hook in >>> /usr/local/share/perl5/Dancer/**Hook.pm l. 58 >>> [8425] core @0.090481> [hit #1]response: 200 in >>> /usr/local/share/perl5/Dancer/**Handler.pm l. 179 >>> [8426] debug @0.000009> vars out hook in /home/faxexpert/DancerFx/lib/** >>> fx/outils.pm l. 29 >>> >>> vars out hook is empty... >>> >>> >> Do you really use >> >> debug "vars out hook" . vars->{'numclient'}; >> >> outside a route? >> >> In this case, vars isn't populated as you don't have a current request. >> >> Regards >> Racke >> >> > ______________________________**_________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/**mailman/listinfo/dancer-users<http://lists.preshweb.co.uk/mailman/listinfo/dancer-users> >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
