>> PylonsApp seems to do two separate things: >> >> - construct and register objects like request, response, session, g, >> h, ... >> - dispatch the request to correct controller (and wrap it with >> testing support and error handling) >> >> Couldn't those two be separated? >> (...) > > > I've been thinking about something similar, that WebOb has made WSGI > obsolete. WSGI will have to change anyway in Python 3 due to the > changing relationship of string to Unicode. (...)
Well, Python3, WSGI2, etc. Years. > In the meantime, WebOb has a design pattern to make writing middleware > much easier. See "Writing your own middleware with WebOb" in What's > New in Pylons 0.9.7. > http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 I do not quite trust this code (what is my_wsgi_application, why (class) insteado of (object)...), but let's leave it. The main question is that here one is still re-creating Request object. What I suggest is that some middleware should create request once and for good, so lower layers are able to reuse it. > As for getting the session, it's in a WSGI environment variable. > environ['beaker.session'] and environ['beaker.get_session'](), it > looks like. Accessing the Pylons globals (pylons.request, > pylons.response, pylons.session) means you're going through > StackedObjectProxies, which just adds complication. Well, one thing StackedObjectProxies do is that I do not need to pass environ to every function anymore, referring pseudo-globals is easier and smoother. PS I roughly did the aforementioned split, can post it if somebody is interested. Not much testing so far though. -- ---------------------------------------------------------------------- | Marcin Kasperski | Users typically do not know exactly what | http://mekk.waw.pl | they want and are unable to articulate all | | that they know. (Parnas) ---------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
