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__ 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