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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.