Mike Orr wrote:
> On Dec 18, 2007 1:40 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Hi Ben,
>>
>> I wholeheartedly agree and I like the idea of explicit session imports from
>> things like Beaker too so everything is explicit. The less work the user
>> has to do to find out what is actually going on the better in my view, even
>> if it makes Pylons *look* less like an integrated framework.
>>
>> g should be renamed persist. The interesting thing about g isn't that it is
>> global, rather that the variables attached to it persist across requests.
> 
> The interesting thing about 'g' is, um... is there anything
> interesting about it?
> I've found two rare cases for it.  One was for a reference object
> that's built on application startup, which I could just have easily
> put into a module global.  The other was for the SQLAlchemy engine,
> which also worked better as a module global instead.  Oh, another time
> I thought 'g' would be a good place for thread-unsafe objects, but
> then found out it's shared between threads.  So what good is it?

I've found it useful for any kind of symbol you would have otherwise
made a module global but needs per-app configuration. For example, the
SA engine you've just mentioned, a port of TG's scheduler I made, a mail
queue, etc...

The fact that Pylons apps are not singletons in the same process (unlike
TG1's) needs some care regarding where you place these kind of "global"
objects since they're not global anymore but "global to an app" (app as
in webapp, or WSGI app... not process).

Binding these to "g" allows several instances of the same app to live
side-by-side in the same process, with different configurations, without
them stepping into each others toes.

Alberto


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to