[open-ils-commits] r38 - in servres/trunk/conifer: . syrup
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Nov 20 19:13:56 EST 2008
Author: gfawcett
Date: 2008-11-20 19:13:56 -0500 (Thu, 20 Nov 2008)
New Revision: 38
Modified:
servres/trunk/conifer/genshi_namespace.py
servres/trunk/conifer/genshi_support.py
servres/trunk/conifer/syrup/models.py
Log:
minor refactoring and docification of genshi support
Modified: servres/trunk/conifer/genshi_namespace.py
===================================================================
--- servres/trunk/conifer/genshi_namespace.py 2008-11-20 20:45:10 UTC (rev 37)
+++ servres/trunk/conifer/genshi_namespace.py 2008-11-21 00:13:56 UTC (rev 38)
@@ -1,2 +1,9 @@
-from itertools import cycle, islice # etc.
-from os.path import isfile # for example
+# genshi_namespace
+
+# Toplevel definitions in this module will be available in when
+# rendering a Genshi template.
+
+from itertools import cycle
+
+from conifer.syrup import models
+
Modified: servres/trunk/conifer/genshi_support.py
===================================================================
--- servres/trunk/conifer/genshi_support.py 2008-11-20 20:45:10 UTC (rev 37)
+++ servres/trunk/conifer/genshi_support.py 2008-11-21 00:13:56 UTC (rev 38)
@@ -5,10 +5,12 @@
from genshi.builder import tag
import genshi.output
from django.conf import settings
-from conifer.syrup import models # fixme, tight binding
import gettext
from conifer.middleware.genshi_locals import get_request
+#------------------------------------------------------------
+# set up internationalization
+
if settings.USE_I18N:
translations = gettext.GNUTranslations(
file('locale/%s/LC_MESSAGES/conifer-syrup.mo' % settings.LANGUAGE_CODE))
@@ -20,6 +22,7 @@
if settings.USE_I18N:
template.filters.insert(0, Translator(translations.ugettext))
+
dirs = ['templates']
loader = TemplateLoader(dirs, auto_reload=True, callback=template_loaded)
@@ -27,14 +30,17 @@
def template(tname):
return loader.load(tname)
-def render(tname, **kwargs):
- request = get_request()
- _inject_django_things_into_namespace(request, kwargs)
- return HttpResponse(template(tname).generate(**kwargs).render('xhtml'))
def _inject_django_things_into_namespace(request, ns):
ns['_'] = _
- ns['models'] = models
ns['request'] = request
ns['user'] = getattr(request, 'user', None)
ns.update(genshi_namespace.__dict__)
+
+#------------------------------------------------------------
+# main API
+
+def render(tname, **kwargs):
+ request = get_request()
+ _inject_django_things_into_namespace(request, kwargs)
+ return HttpResponse(template(tname).generate(**kwargs).render('xhtml'))
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2008-11-20 20:45:10 UTC (rev 37)
+++ servres/trunk/conifer/syrup/models.py 2008-11-21 00:13:56 UTC (rev 38)
@@ -22,6 +22,7 @@
if not k.startswith('_')]:
setattr(User, k, v)
+
class UserProfile(m.Model):
user = m.ForeignKey(User, unique=True)
home_phone = m.CharField(max_length=100, blank=True)
More information about the open-ils-commits
mailing list