Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: mason request scope variable

by themage (Friar)
on Jan 16, 2007 at 13:02 UTC ( #594902=note: print w/ replies, xml ) Need Help??


in reply to mason request scope variable

Hi jeteve,

I use Mason for almost everything I write to web. The way I usually do this is by passing the session variable as parameter to the $m->call_next(session=>$session);

However, I don't use <%init>, <%once>, <%cleanup> or <%filter> (I used <%filter> once). The main reason I don't use them is that the code turn into a less predictable code.

For instance, in this code:

<%cleanup> print "Cleanup"; </%cleanup> <%init> print "Init"; #This is an alias to $m->out(); </%init> <%filter> print "Filter"; </%filter> <%perl> print "Perl"; </%perl> <%once> print "Once"; </%once>
Can anyone say which of the blocks will be called first? I don't, and don't want to be always looking for the next (or previous) code block, so I just use (most of the time) the <%perl> and <%args>. You can do everything you need using just this too, and your code is a lot more linear.

For situations identical to yours, my code usually looks like (in the autohandler):
<%perl> my $session=$m->comp('/mason/session/session.mas'); $m->call_next(session=>$session); $m->comp('/mason/session/session.mas', action=>'save', session=>$sessi +on); </%perl>
Hope this helps you.


Comment on Re: mason request scope variable
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2015-07-29 03:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls