Re: Other Globals in %once
David Wheeler <[email protected]>
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
On May 2, 2004, at 7:37 AM, Jonathan Swartz wrote:
> I'm opposed to it, for these reasons:
>
> 1. $m isn't guaranteed to be defined in <%once>, since you can load a
> component outside the context of a request, e.g. when preloading. I
> don't
> think a component should stop working when you preload it. That's a
> decision
> that might be made by someone far from the person developing the
> component.
Ah, excellent point.
> 2. As Serge points out, <%once> may execute or not execute for any
> arbitrary
> request, depending on the whim of the component cache. So you
> shouldn't be
> defining anything in <%once> that depends on the current request ($m).
Another good point.
> David, I'm not clear on what you were planning to use $m for in
> <%once>. Was
> it for something that would always be the same regardless of the
> current
> request?
Yes, for example, calling $m->comp() on a utility template to set up
some variables for use during the request. For example, for Radio Free
Asia, we might have something like this:
<%once>;
my $service_name = $m->comp('/util/get_service_name.mc');
</%once>
But that applies mainly to Bricolage, since for a Web site, the service
name would change for each request. What we're running into here is the
difference between a persistent request environment like your typical
Mason Web server, and a non-persistent environment like Bricolage,
where the interpreter lasts only for the duration of formatting a
single story.
At any rate, your arguments are good ones; I can just add something to
our FAQ to say that $m isn't available in %once blocks; and maybe I can
add an exec() method to our burner object (now available in %once
blocks) that can do what comp() does (using $interp->exec).
Regards,
David
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click