utils - Utility methods
Deprecation warning: these utility methods and modules are provided only for convience of Wille development.
For copyright information and licensing, see LICENSE.txt
JSONEncoder subclass that knows how to encode date/time and decimal types.
Checks to see if any loaded modules have changed on disk and, if so, reloads them.
Function has been taken from web.py <http://webpy.org> version 0.33 by Anand Chitipothu, made available under Public domain. Modifications have been made for Wille.
Creates a temporary copy from specified folder that is deleted automatically on garbage-collection
Safe way for reading and returning given file Parameters: shared_dir - Directory from which file is served filename - Filename under the given directory
Send headers based on given metadata
Generate random string (from letters) of given length
Utility function for registering given location as a python module.
template - Light-weight template engine
Simple templatefile renderer, supporting ${xyz} style variables
Returns: rendered template as unicode() object
data - Template string vars - Dictionary of variables with they content vars_encoding - Default encoding for plaintext variables
(enforced if template is in unicode format)
Rendering in cases of 0-2 vars:
>>> from template import render_str
>>> render_str('Hello World!')
'Hello World!'
>>> render_str('Hello ${world}!', {'world': 'World'})
'Hello World!'
>>> render_str('${hello} ${world}!', {'hello': 'Hello', 'world': 'World'})
'Hello World!'
>>> render_str(u'1234\u1234\n').encode('utf-8')
'1234\u1234\n'
# (Note that above we have escaped all backslashes to make code work # in doctest)