Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Ian Bicking
Phillip J. Eby wrote: I don't object to stuffing things in the environment; I object to: 1. Putting APIs in there (the API should be regular functions or objects, thanks) 2. Wrapping middleware around an app to put in APIs that it's going to have to know about anyway. Well, sometimes this oc

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Phillip J. Eby
At 02:12 PM 7/7/2008 -0700, Donovan Preston wrote: It seems to me that what is really needed here is an extension of wsgi that specifies how to get, set, and list request local storage, and for people to use that instead of the threadlocal module. I don't follow why you wouldn't just put that i

Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Phillip J. Eby
At 04:36 PM 7/7/2008 -0500, Ian Bicking wrote: Phillip J. Eby wrote: At 09:58 PM 7/7/2008 +0200, Manlio Perillo wrote: In this case the first solution is to use this middleware as a decorator, instead of a full middleware. This is the correct way to implement non-transparent middleware; i.e.,

Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Phillip J. Eby
At 11:21 PM 7/7/2008 +0200, Manlio Perillo wrote: So this is not a "bad" middleware, IMHO. True, but it's part of the application, rather than being transparent. By the way, a middleware that is responsible for user authentication: http://hg.mperillo.ath.cx/wsgix/file/tip/wsgix/auth/http_midd

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Donovan Preston
On Jul 4, 2008, at 12:10 PM, Ian Bicking wrote: Iwan Vosloo wrote: Many web frameworks and ORM tools have the need to propagate data depending on some or other context within which a request is dealt with. Passing it all via parameters to every nook of your code is cumbersome. A lot of th

Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Ian Bicking
Phillip J. Eby wrote: At 09:58 PM 7/7/2008 +0200, Manlio Perillo wrote: In this case the first solution is to use this middleware as a decorator, instead of a full middleware. This is the correct way to implement non-transparent middleware; i.e., so-called middleware which is in fact an appli

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Ian Bicking
Donovan Preston wrote: To throw another wrench in things, with the Paste/WebError evalexception interactive exception handler, it restores this thread-local context so you can later execute expressions in the same context. It seems to me that what is really needed here is an extension of wsgi

Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Manlio Perillo
Phillip J. Eby ha scritto: At 09:58 PM 7/7/2008 +0200, Manlio Perillo wrote: In this case the first solution is to use this middleware as a decorator, instead of a full middleware. This is the correct way to implement non-transparent middleware; i.e., so-called middleware which is in fact an

Re: [Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Phillip J. Eby
At 09:58 PM 7/7/2008 +0200, Manlio Perillo wrote: In this case the first solution is to use this middleware as a decorator, instead of a full middleware. This is the correct way to implement non-transparent middleware; i.e., so-called middleware which is in fact an application API. See: htt

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Ian Bicking
Manlio Perillo wrote: Ian Bicking ha scritto: Manlio Perillo wrote: [...] As an example, in Paste you have choosed to using config dictionary for middleware configuration, that is, you have middleware factories. I think this is a red herring. WebOb specifically doesn't do anything related

[Web-SIG] help with the implementation of a WSGI middleware

2008-07-07 Thread Manlio Perillo
As I have informally written in previous messages, I'm writing a small WSGI framework. The framework is available here (a Mercurial repository): http://hg.mperillo.ath.cx/wsgix In wsgix I have written two middleware that I find interesting since I have learned a bit more about how to write mi

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Manlio Perillo
Ian Bicking ha scritto: Manlio Perillo wrote: [...] As an example, in Paste you have choosed to using config dictionary for middleware configuration, that is, you have middleware factories. I think this is a red herring. WebOb specifically doesn't do anything related to configuration or th

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Robert Brewer
Matt Goodall wrote: > Yes, it can be tedious but I believe explicit arg passing > is necessary to make code readable, testable and reusable. > ... > I've made the mistake of relying on magic contexts in the > past. I'm still trying to fix things. Can you elaborate? Robert Brewer [EMAIL PROTECTED

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Ian Bicking
Manlio Perillo wrote: Ian Bicking ha scritto: Manlio Perillo wrote: I'm adding web-sig in Cc. [...] I'm developing a WSGI framework with all these (and other) ideas: http://hg.mperillo.ath.cx/wsgix Its still not documented, so I have not yet made an official announcement. The main desi

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Manlio Perillo
Ian Bicking ha scritto: Manlio Perillo wrote: I'm adding web-sig in Cc. [...] I'm developing a WSGI framework with all these (and other) ideas: http://hg.mperillo.ath.cx/wsgix Its still not documented, so I have not yet made an official announcement. The main design goal is to keep the

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Manlio Perillo
Matt Goodall ha scritto: [...] True, but even passing a request or env dict around to everyone gets tedious don't you think? Yes, it can be tedious but I believe explicit arg passing is necessary to make code readable, testable and reusable. If it's web-related code then give it the request,

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Iwan Vosloo
On Mon, 2008-07-07 at 13:48 +0100, Matt Goodall wrote: > Iwan Vosloo wrote: > > On Fri, 2008-07-04 at 13:39 +0100, Matt Goodall wrote: > >> The ideal solution is, of course, to pass everything around to whatever > >> needs it. However, there's really tedious at times. > >> > >> Whatever the archite

Re: [Web-SIG] Alternative to threading.local, based on the stack

2008-07-07 Thread Matt Goodall
Iwan Vosloo wrote: > On Fri, 2008-07-04 at 13:39 +0100, Matt Goodall wrote: >> Iwan Vosloo wrote: >> You're correct that Twisted Web does not allocate a thread per request. >> All requests are handled by an event loop in the main thread. > >> In Twisted, the call stack tends to gets fragmented dur