A few Django 1.1 functions someone may find useful.
Project management
django.utils.version.get_svn_revision
def get_svn_revision(path=None):
"""
Returns the SVN revision in the form SVN-XXXX,
where XXXX is the revision number.
Returns SVN-unknown if anything goes wrong, such as an unexpected
format of internal SVN files.
If path is provided, it should be a directory whose SVN info you want to
inspect. If it's not provided, this will use the root django/ package
directory.
"""
Python helpers
django.utils.importlib.import_module
def import_module(name, package=None):
"""Import a module.
The 'package' argument is required when performing a relative import. It
specifies the package to use as the anchor point from which to resolve the
relative import to an absolute import.
"""
django.utils._os.safe_join
def safe_join(base, *paths):
"""
Joins one or more path components to the base path component intelligently.
Returns a normalized, absolute version of the final path.
The final path must be located inside of the base path component (otherwise
a ValueError is raised).
"""
django.utils.daemonize.become_daemon
def become_daemon(our_home_dir='.', out_log='/dev/null',
err_log='/dev/null', umask=022):
"Robustly turn into a UNIX daemon, running in our_home_dir."
from django.utils.itercompat
"""
Providing iterator functions that are not in all version of Python we support.
Where possible, we try to use the system-native version and only fall back to
these implementations if necessary.
"""
Dates
django.utils.feedgenerator.rfc2822_date
def rfc2822_date(date):
[...]
return date.strftime('%a, %d %b %Y %H:%M:%S -0000')
django.utils.feedgenerator.rfc3339_date
def rfc3339_date(date):
[...]
return date.strftime('%Y-%m-%dT%H:%M:%SZ')