Hello,

Your mason pages run inside the HTML::Mason::Commands package, so that is
where the stuff needs to be exported to.  When you use the modules in your
MyApp::LoadMods module, they get imported into the MyApp::LoadMods
package.

So instead, you can switch to the HTML::Mason::Commands package before you
use the modules that export stuff.  This will cause it to get exported
into the HTML::Mason::Commands package and your mason pages will be able
to use the exported things.

Example MyApp/LoadMods.pm:

package HTML::Mason::Commands;
use this;
use that;

1;


More information:
http://www.masonhq.com/docs/manual/Admin.html#external_modules
http://www.masonhq.com/?FAQ:Components#h-can_i_use_globals_in_components_

Hope that helps.
Bradley C Bailey


> I've been in the process of converting some of my code into a series of
> modules. I'm new to module
> writing so this is probably an easy question of something I'm missing.
>
> I've added a module to my Apache config that loads all my other modules to
> take advantage of the
> memory savings.
>
> MyApp::LoadMods includes a bunch of:
>
> use MyApp::Thing1;
> use MyApp::Thing2;
>
> etc. The problem is that when I go to use the function inside those
> modules in my Mason components,
> I get errors saying they aren't defined. If I add the 'use MyApp::Thing1'
> statements into my
> /syshandler component, then they all work. How do I get access to the
> functions without specifying
> 'MyApp::function' everywhere but still get the memory savings of loading
> them in Apache? Does it
> hurt to load them again (?) in the /syshandler.
>
> Like I say, I'm new to using modules I've written so any suggestions would
> be appreciated. I know
> just enough to know I'm dumb in this area so there's no answers too basic
> for me. :)
>
>
> -- Matt Grommes --
> -- mattorama.net --
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users
>




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to