On Mon, Jun 2, 2008 at 11:43 AM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
>
> I'm prepping some software for release as a 'platform', and realized
> that it might seem to better suit our purposes if we re-implmented a c
> and g as our own vars, instead of creating a new namespace within
> each.  I'd like to explore/test this approach.
>
> According to pylons/__init__.py , they're both
> paste.registry.StackedObjectProxy objects
>
> I can't seem to find out where c gets (re?)initialized every request.
> I figured it might be in middleware somewhere, but I couldn't find
> it.   Any clues would be appreciated.

It goes something like this:

- ``pylons.__init__`` defines ``c`` and ``g`` as
``StackedObjectProxy`` instances.

- middleware.py creates a RegistryManager, which is a middleware
layer.  If I understand correctly, this is essentially a scope
boundary; i.e., managed variables can have a different value outside
this middleware layer than inside.  The registry is stored in the WSGI
environment under "paste.registry".  Details in the ``paste.registry``
module docstrings.

- When the Pylons app is called, the proper values for ``c`` and ``g``
are pushed onto the globals.  This is done by "registering" the values
with the registry manager.  ``c`` is created for each request, while
``g`` is a ``PylonsApp`` instance variable.  Remember that
StackedObjectProxy'ies have a ``._current_obj()`` method that returns
the underlying value via the registry manager, and it also attempts to
transparently delegate key lookups and method calls to the underlying
object.

The actual ``c`` and ``g`` objects are also stored in some other
places, I'm not sure exactly where but look in the controller instance
and WSGI environment.  Supposedly it's possible to access these values
in the action method without using the StackedObjectProxy'ies,
although I've never done it.

The Pylons Execution Analysis gives more background info.
http://wiki.pylonshq.com/display/pylonscookbook/Pylons+Execution+Analysis+0.9.6

-- 
Mike Orr <[EMAIL PROTECTED]>

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

Reply via email to