Author: dmeyer
Date: Sun Jan 29 12:00:42 2006
New Revision: 1139

Modified:
   trunk/cherrypy/src/__init__.py
   trunk/cherrypy/src/controller.py

Log:
add template helper functions

Modified: trunk/cherrypy/src/__init__.py
==============================================================================
--- trunk/cherrypy/src/__init__.py      (original)
+++ trunk/cherrypy/src/__init__.py      Sun Jan 29 12:00:42 2006
@@ -34,4 +34,4 @@
 # kaa.cherrypy imports
 from config import config
 from server import start
-from controller import expose, Template
+from controller import expose, Template, template, thread_template

Modified: trunk/cherrypy/src/controller.py
==============================================================================
--- trunk/cherrypy/src/controller.py    (original)
+++ trunk/cherrypy/src/controller.py    Sun Jan 29 12:00:42 2006
@@ -31,7 +31,7 @@
 #
 # -----------------------------------------------------------------------------
 
-__all__ = [ 'expose', 'Template' ]
+__all__ = [ 'expose', 'Template', 'template', 'thread_template' ]
 
 # python imports
 import types
@@ -184,8 +184,33 @@
 
 
     @expose()
-    def render(self, **attributes):
+    def render_mainloop(self, **attributes):
         """
         Render the template with the given attributes.
+        This function is exposed to run in the main loop.
         """
         return self.engine.parse(self.template, attributes)
+
+    @expose(mainloop=False)
+    def render_thread(self, **attributes):
+        """
+        Render the template with the given attributes.
+        This function is exposed to run in a thread
+        """
+        return self.engine.parse(self.template, attributes)
+
+
+def template(template, engine=None):
+    """
+    Return an exposed render function for the template to run in the
+    main loop.
+    """
+    return Template(template, engine).render_mainloop
+
+
+def thread_template(template, engine=None):
+    """
+    Return an exposed render function for the template to run in a
+    thread.
+    """
+    return Template(template, engine).render_thread


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to