Ian Bicking: the old part of his blog

What can WSGIKit do for you?

Note: WSGIKit has been renamed as Python Paste

Well, I tried to explain WSGIKit, but I'm not entirely sure how successful that was. People asked for diagrams, but I don't think in terms of diagrams (even if I appreciate that it's very useful for other people), so I'm not sure what one would look like. I made a couple diagrams for my WSGIKit PyCon presentation, which may or may not help.

But anyway, I want to write about what WSGIKit can do for you, the framework developer. To do this, I want to explain Webware's relation to WSGIKit, which is a concrete example of how this stuff can fit together.

OK, so if you set up your framework to work with WSGIKit, what would you get out of it?

I also think the test and documentation framework is heading in a good direction.

You don't have to use all of this to pick features and code out of WSGIKit if you wish. A lot of what I'm looking to provide with WSGIKit is a good experience for users, both new and experienced, and part of what that means is having other people put things together in intelligent ways instead of leaving it up to each developer to do so. Wouldn't it be great to tell someone evaluating Python web programming to download one (maybe big) hunk of code, run app-setup list to see a dozen available Python frameworks, app-setup list -v to get extended descriptions, app-setup --template=X create ~/test_X; cd ~/test_X; wsgi-server to get a demo of any of the frameworks set up? That's not the end-all-be-all of resolving issues with Python web development, but I think it's an accessible goal right now, and worth doing.

Created 16 Apr '05
Modified 23 Apr '05


when you say it detects stale code, how deep does the detection reach?

let's say I have a servlet script A. inside A it says ... import foo ...

does wsgikit detect changes to foo?

# Jonathan Ellis

WSGIKit looks through all the modules in sys.modules and restarts the entire server if one of them changes. It is not initiated by a request, but rather runs in a separate thread and polls the files regularly. You can also make it look at extra files, like a configuration file, and restart when those change too. It doesn't reload modules, which is much more challenging to do correctly, though at some point I'll probably have it look at modules and see if some are explicitly marked to be reloadable. E.g., Webware servlet files (but not the files they import) can generally be reloaded.
# Ian Bicking

Yeah, restarting is the easy way out. No shame in taking the easy way sometimes! That is what Spyce has to do for anything it doesn't compile itself.
# Jonathan Ellis

BTW, to accomodate pathnames with spaces in them (common on Windows) you may want your reloader code to do something like this

args = ['"' + re.sub('"', r'"', i) + '"' for i in args]

before spawning the subprocess.

I also like to run python -u (if the speed hit matters they shouldn't have the modules checker turned on).

# Jonathan Ellis

eh, your wiki nuked the backslash in that sub() call.
# Jonathan Ellis

What happens if you use literal block text, like so:


Yep. Seems to work.

Your pycon presentation is exactly what i needed to understand wsgi and wsgikit ! thanks
# anonymous

Given the current state of Python web programming I would say that WSGI is a good standard to leverage, but I don't think that "thin glue" accurately describes a real-world WSGI implementation. Even if WSGI is the most efficient way to bring the plethora of ideas into focus, it's really more like "thick glue" or "mortar". Fitting some of this stuff together is more like building with rocks than bricks. If this analogy is good, then the goal is not to chip every piece into a new shape, but to knock off the protruding edges so that they can be fitted.
# Eric Radman