I'm a bad person, but one use case I have is for shuffling templates around such that:

* An inherited ('parent') template can be stored in a database.
* The 'views' of my application are told to either use the real master template or the db parent template.
* The rendering engine loads the parent from disk.

Thus I create a NamedTemporaryFile (with some custom prefix and suffix stuff), write the parent template from DB to it, flush, then let the rendering engine do its thing. Works like a hot damn, and lets the users of my CMS manage custom layouts from within the CMS.

Templates are cached using the CMS template path as the dict key, and a 2-tuple of modification time and the NamedTemporaryFile as the value. Cleanup of old versions on-disk is simple: just close the file!

        - Alice.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to