[Checkins] SVN: cmf.pt/trunk/ Added missing '_exec' method.

Malthe Borch mborch at gmail.com
Fri Feb 13 11:57:27 EST 2009


Log message for revision 96497:
  Added missing '_exec' method.

Changed:
  U   cmf.pt/trunk/CHANGES.txt
  U   cmf.pt/trunk/src/cmf/pt/fs.py

-=-
Modified: cmf.pt/trunk/CHANGES.txt
===================================================================
--- cmf.pt/trunk/CHANGES.txt	2009-02-13 16:55:32 UTC (rev 96496)
+++ cmf.pt/trunk/CHANGES.txt	2009-02-13 16:57:26 UTC (rev 96497)
@@ -1,6 +1,12 @@
 Changelog
 =========
 
+In next release
+
+ - Added ``_exec`` method to the file-system based skin template
+   class, largely carried over from
+   ``Products.PageTemplates``. [malthe]
+
 cmf.pt 0.2 (released 12/17/2008)
 
  - The ``func_code`` attribute of file-system page templates should

Modified: cmf.pt/trunk/src/cmf/pt/fs.py
===================================================================
--- cmf.pt/trunk/src/cmf/pt/fs.py	2009-02-13 16:55:32 UTC (rev 96496)
+++ cmf.pt/trunk/src/cmf/pt/fs.py	2009-02-13 16:57:26 UTC (rev 96497)
@@ -11,6 +11,7 @@
 from Shared.DC.Scripts.Script import Script
 from Shared.DC.Scripts.Signature import FuncCode
 from AccessControl import ClassSecurityInfo
+from AccessControl import getSecurityManager
 from RestrictedPython import Utilities
 
 from five.pt.pagetemplate import BaseTemplateFile
@@ -44,6 +45,19 @@
         kwargs['args'] = args
         return BaseTemplateFile.__call__(self, self, **kwargs)    
 
+    def _exec(self, bound_names, *args, **kwargs):
+        # execute the template in a new security context.
+        security = getSecurityManager()
+        bound_names['user'] = security.getUser()
+        security.addContext(self)
+
+        try:
+            kwargs.update(bound_names)
+            kwargs['extra_context'] = bound_names
+            return self(*args, **kwargs)
+        finally:
+            security.removeContext(self)
+
 class FSControllerPageTemplate(FSPageTemplate, FSControllerBase, BaseCPT):
     def __init__(self, id, filepath, fullname=None, properties=None):
         FSPageTemplate.__init__(self, id, filepath, fullname, properties)  



More information about the Checkins mailing list