Re: simpler replacement for <%shared>
Jonathan Swartz <[email protected]>
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
> On Tue, 28 Sep 2004, Jonathan Swartz wrote: > >>We can provide almost the same functionality in a simpler, more reliable >>way with a restricted block that simply declares one or more shared >>request variables. e.g. >> <%request_vars> >>Beyond implementation simplicity and efficiency, this section has >>several advantages over <%shared>: > > Can you say anything about the implementation? > How is it implemented differently from <%shared> variables, or declaring > "my $var" inside a <%once> section? It is a much simpler implementation. The "my $var" declarations are placed in the same place as <%once> code. At the beginning of the main component and each subcomponent/method, we call a local '_clear_request_vars' routine that undefs the variables. We also register the component with a cleanup list stored in the request, so that at the end of the request, Mason calls '_clear_request_vars' again on each of these components. The redundant calls are to make absolutely sure data doesn't leak between requests. Guess the easiest way to show it is to check it in. I'll use request_vars for the purpose of check-in but acknowledge that the name is open to debate. > > >>* Mason can automatically cleanup the values of each request var at the >>end of the request. Variables declared in <%shared> cannot be >>automatically cleaned up and thus often look like leaks. > > > Will it happen even with exceptions and aborts? (unlike <%cleanup>) Yes - see above. Fixing <%cleanup> is another matter (http://www.masonhq.com/resources/todo/view.html?id=510) but this could use the same cleanup registry mechanism as above. Jon ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl