[Checkins] SVN: z3c.pt/trunk/ Source code is now written to disk in debug-mode.

Malthe Borch mborch at gmail.com
Mon Sep 8 11:41:06 EDT 2008


Log message for revision 90953:
  Source code is now written to disk in debug-mode.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/template.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-09-08 15:39:19 UTC (rev 90952)
+++ z3c.pt/trunk/CHANGES.txt	2008-09-08 15:41:05 UTC (rev 90953)
@@ -15,6 +15,8 @@
 
   Features
 
+- Source-code is now written to disk in debug mode. [malthe]
+  
 - Custom validation error is now raised if inserted string does not
   validate (when debug mode is enabled). [malthe]
 

Modified: z3c.pt/trunk/src/z3c/pt/template.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/template.py	2008-09-08 15:39:19 UTC (rev 90952)
+++ z3c.pt/trunk/src/z3c/pt/template.py	2008-09-08 15:41:05 UTC (rev 90953)
@@ -129,6 +129,17 @@
         self.signature = hash(body)
         self._v_last_read = self.mtime()
 
+    def cook(self, **kwargs):
+        template = self.compiler(**kwargs)
+
+        if config.DEBUG_MODE:
+            filename = "%s.py" % self.filename
+            f = open(filename, 'w')
+            f.write(template.source)
+            f.close()
+
+        return template
+
     def cook_check(self, *args):
         if self.auto_reload and self._v_last_read != self.mtime():
             self.read()



More information about the Checkins mailing list