You may be recursing... Your

<%shared>
<& /mason/subroutines.mas &>
</%shared>

in your autohandler may be invoking the autohandler again. I'm not certain.

I think you'd be best served by putting common subroutines in a Perl module which you then 'use' from wherever you need it, just like normal Perl code. I'd save using Mason components for times when you need to mix HTML and Perl... if what you're doing is really Perl, then I'd do pure Perl.

You could put the 'use' statement in your autohandler.

There's a convention that's developed of using a 'syshandler'... Mason doesn't implicitly do anything with a 'syshandler'; you have to invoke it yourself, for instance, adding this to your autohandler:

<%flags>
 inherit => '/syshandler'
</%flags>

The idea is to separate out your setup code from your presentation code. Let autohandler provide whatever page framing or common HTML you want across all your pages... let syshandler do your database setup or whatever other initialization you may need. It's just a cleaner way of separating the two things. Again, it's just a handy coding convention.

Here's a syshandler I'm using right now:

<%once>
 use lib '/Users/romkey/src/hvac3/trunk/src';

 use HVAC qw/system units onedecimal get_value/;
 use HVAC::Setup;

 use JACE;

</%once>
<%flags>
inherit => undef
</%flags>

Rather than defining the functions that are in the HVAC and HVAC::Setup packages, I just use them here. Doing this also makes it a lot easier to develop them outside of Mason, debug them, and test them.

You turn off inherit to make sure the syshandler isn't accidentally invoking the autohandler again, so you don't get a loop. (you might try putting this <%flags> section in your subroutines.mas file to make sure you're not accidentally getting into an autohandler loop).

I don't believe that syshandler's are covered by the Mason book, but you can read about them in the mailing list archives. There's a good explanation at http://marc.theaimsgroup.com/?l=mason&m=114235208411396&w=2

Anyway, I'd recommend not defining your Perl subroutine in Mason, but in Perl, and then use'ing its package to make it available to your components.
   - john romkey
   http://www.romkey.com/





-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to