You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jonathan Vanasco <jo...@2xlp.com> on 2006/05/27 07:28:12 UTC
sharing data within a handler (but not across)
long story short:
i built my own mvc framework. i specifically wanted to keep apache
related stuff out of the model when designing it, but i was in the
situation where i needed to access it for a quick hack ( i chose the
longer elegant solution that negated touching it ) and said "hm... i
wonder how could i do this"
i know i could store stuff in a pnote, but thats shared across
handlers- i wanted to make sure this variable was available only to
the current handler without implementing my own cleanup at the end to
undef the var.
i ended up just tossing a factory pattern into a namespace in the
handler to get me the needed information -- but it makes me wonder if
there's any per-handler style verison of a pnote.
| - - - - - - - - - - - - - - - - - - - -
| RoadSound.com / Indie-Rock.net
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - -
Re: sharing data within a handler (but not across)
Posted by John ORourke <jo...@versatilia.com>.
Jonathan Vanasco wrote:
> i specifically wanted to keep apache related stuff out of the model
> when designing it, but i was in the situation where i needed to
> access it for a quick hack ( i chose the longer elegant solution that
> negated touching it ) and said "hm... i wonder how could i do this"
It really hard work - I built a framework which used one instance of its
main module per Apache instance, and the handler would then call methods
on it (so it could implement caching and so on). The following were big
issues:
- a file upload module which of course needed access to the
Apache2::Upload object
- several modules which create URLs needed document_root and other
request info
- cleanup - each module in my framework needs to refer to the main
object and so stores a reference to it, but this makes garbage
collection nearly impossible. I've seen a solution to this in the
SOAP::Lite modules but haven't had time to find out how it works - I had
to get very intimate with the Apache2::SOAP source to talk to a .NET
SOAP client.
As an ex assembler programmer I try not to use abstraction for
abstraction's sake, so decided that my framework would only have to work
with Apache2/MP2 or stand-alone. Made life lots easier.
I also asked myself afterwards why we keep reinventing the wheel!
John