[Python-Dev] [Web-SIG] Adding wsgiref to stdlib (original) (raw)
Ian Bicking ianb at colorstudy.com
Fri Apr 28 22:50:59 CEST 2006
- Previous message: [Python-Dev] [Web-SIG] Adding wsgiref to stdlib
- Next message: [Python-Dev] Adding wsgiref to stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Phillip J. Eby wrote:
I'd like to include paste.lint with that as well (as wsgiref.lint or whatever). Since the last discussion I enumerated in the docstring all the checks it does. There's still some outstanding issues, mostly where I'm not sure if it is too restrictive (marked with @@ in the source). It's at:
http://svn.pythonpaste.org/Paste/trunk/paste/lint.py +1, but lose the unused 'globalconf' parameter and 'makemiddleware' functions.
Yeah, those are just related to Paste Deploy and wouldn't go in.
I think another useful addition would be some prefix-based dispatcher, similar to paste.urlmap (but probably a bit simpler): http://svn.pythonpaste.org/Paste/trunk/paste/urlmap.py
I'd rather see something a lot simpler - something that just takes a dictionary mapping names to application objects, and parses path segments using wsgiref functions. That way, its usefulness as an example wouldn't be obscured by having too many features. Such a thing would still be quite useful, and would illustrate how to do more sophisticated dispatching. Something more or less like: from wsgiref.util import shiftpathinfo # usage: # mainapp = AppMap(foo=partone, bar=parttwo, ...) class AppMap: def init(self, **apps): self.apps = apps def call(self, environ, startresponse): name = shiftpathinfo(environ) if name is None: return self.default(environ, startresponse) elif name in self.apps: return self.appsname return self.notfound(environ, startresponse) def default(self, environ, startresponse): self.notfound(environ, startresponse) def notfound(self, environ, startresponse): # code to generate a 404 response here This should be short enough to highlight the concept, while still providing a few hooks for subclassing.
That's mostly what I was thinking, though using a full prefix (instead of just a single path segment), and the default is the application at '', like in my other email.
paste.urlmap has several features I wouldn't propose (like domain and port matching, more Paste Deploy stuff, and a proxy object that I should probably just delete); I probably should have been more specific. URLMap's dictionary interface isn't that useful either.
Another feature that the example in my other email doesn't have is / handling, specifically redirecting /something-that-matches to /something-that-matches/ (something Apache's Alias doesn't do but should).
Host and port matching is pretty easy to do at the same time, and in my experience can be useful to do at the same time, but I don't really care if that feature goes in.
-- Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
- Previous message: [Python-Dev] [Web-SIG] Adding wsgiref to stdlib
- Next message: [Python-Dev] Adding wsgiref to stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]