I've been poking around the internals of Django with the goal of understanding how I might dynamically load and unload templates such that each thing in spaces can have its own little branch of the URL tree in order to respond to requests for both HTML UIs and RESTful APIs. Basically, I want a template to be able to specify something that looks a lot like a Django app and then map it into and out of URL space on the fly.
There's a bit of overlap with the pluggable app project, in that the template web app needs to work when rooted anywhere in the URL tree and there will be multiple copies of the template web app loaded in the same Django process.
So, I've prodded Django's RegexURLResolver and now I can map from an incoming URL to a template's view method using the template's url patterns. That's part of the battle, with the remainder revolving around how to manage loading and unloading the python modules of the template while maintaining enough separation between versions.
I am constantly impressed with the cleanliness of the Django core and I'm learning a lot of nifty patterns while doing things the Django devs never expected.
Comments