On Sep 13, 2007, at 7:06 PM, avdd wrote:

What is the point of StackedObjectProxy for real globals, such as g
and config?  i.e. pylons.wsgiapp has this (simplified) statement
sequence:

Because even for a global thats used across all threads, there's the edge case that you might have a Pylons app as WSGI middleware, *and* a Pylons app underneath it. So when the first Pylons app calls down to the next one, it swaps the global so that each one sees the proper object at the right time.

    # in __init__
    self.config = pylons.config._current_obj()

The config is loaded into a process global during setup, this pulls it back out and the Pylons app instance now has a reference to the real config object.

    # in __call__
    registry.register(pylons.config, self.config)

Now it loads the config back into the global object proxy so that its present during a request execution. Note that if you call down to another Pylons based app, it will put its config in the global during its call, then it will be cleaned up when the other app finishes.

As far as I know, no one (or not many) people are actually using Pylons apps to call more Pylons apps, but this might increase in the future with TG2 also being based off Pylons.

Cheers,
Ben

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to