[CalendarServer-changes] [7897] CalendarServer/branches/users/glyph/imip-and-admin-html/ twistedcaldav/mail.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 11 21:39:35 PDT 2011
Revision: 7897
http://trac.macosforge.org/projects/calendarserver/changeset/7897
Author: glyph at apple.com
Date: 2011-08-11 21:39:35 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
basic shim that makes the one test pass
Modified Paths:
--------------
CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:39:24 UTC (rev 7896)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:39:35 UTC (rev 7897)
@@ -42,6 +42,7 @@
from twisted.plugin import IPlugin
from twisted.python.usage import Options, UsageError
from twisted.web import client
+from twisted.web.template import XMLString
from twext.web2 import server, responsecode
from twext.web2.channel.http import HTTPFactory
@@ -144,6 +145,38 @@
"""
+class StringFormatTemplateLoader(object):
+ """
+ Loader for twisted.web.template that converts a template with %()s slots.
+ """
+ def __init__(self, fileFactory, rendererName):
+ """
+ @param fileFactory: a 1-argument callable which returns a file-like
+ object that contains the %()s-format template.
+
+ @param rendererName: the name of the renderer.
+
+ @type rendererName: C{str}
+ """
+ self.fileFactory = fileFactory
+ self.rendererName = rendererName
+
+
+ def load(self):
+ class FormatterShim(object):
+ def __getitem__(self, item):
+ return "<t:slot name=%r />" % (item,)
+
+ starttag, everything = self.fileFactory().read().split(">", 1)
+ html = starttag + (
+ ' xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"'
+ ' t:render=%r >' % (self.rendererName,))
+ html += everything % FormatterShim()
+ print html
+ return XMLString(html).load()
+
+
+
def localizedLabels(language, canceled, inviteState):
"""
Generate localized labels for an email in the given language.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/998bfb3e/attachment.html>
More information about the calendarserver-changes
mailing list