On Jun 4, 4:22 pm, Mike Orr <[email protected]> wrote:
> On Thu, Jun 4, 2009 at 9:00 AM, Wyatt
>
> Baldwin<[email protected]> wrote:
> >> pylonsapp = make_app(...)
> >> pylonsapp = Middleware1(pylonsapp)
> >> pylonsapp = Middleware2(pylonsapp)
> >> pylonsapp = Middleware3(pylonsapp)
> >> """
>
> >> So in Middleware1, for example, you cannot access Middleware3 and vice 
> >> versa.
>
> > Right. In your example, I want access to the `Middleware3` instance--
> > the WSGI app that is directly served by Paste (or your favorite WSGI
> > server, X). What I was thinking was that the server machinery could
> > place a reference to this "root" app in the WSGI environ. I haven't
> > really thought it through, so perhaps this is a bad idea.
>
> WSGI is nested function calls.  *Function* calls, not an object
> hierarchy.  (A method is just a function with a magic 'self' argument,
> of course.)  So from the perspective of Middleware3.__call__, the only
> way to get to Middleware1.__call__

In my case, I want access to Middleware3.__call__ (or, in other words,
whatever the first WSGI app/function in the chain is--what I've been
calling the "root" app) in a controller precisely so that I can do a
subrequest that goes through the *whole* WSGI stack. The method I'm
using--wrapping everything in an app that puts a reference to itself
in the environ--seems to be working perfectly.

The concern of trashing `c`, et al, as noted by Pawel, doesn't appear
to be a problem being that those objects are "stacked proxies." So,
yes, the subrequest runs in the same thread, but it's not an issue for
`c` and friends because `PylonsApp` always pushes a new `c`,
`request`, `response`, ... onto the stack every time it's __call__ed.


> is to go up through the call stack,
> perhaps by raising and catching an exception and poking through its
> traceback.  But when you get to Middleware1.__call__ you won't be able
> to execute anything in it, because it's suspended waiting for you to
> return, and anything you change would trash its state.
>
> As for getting a reference to Middleware1 so that you can call another
> method, WSGI doesn't do that automatically but Middleware1 could put a
> reference to itself in the environ.
>
> --
> 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