Skip to content
This repository has been archived by the owner on Feb 12, 2020. It is now read-only.

Commit

Permalink
Added missing '_exec' method.
Browse files Browse the repository at this point in the history
  • Loading branch information
malthe committed Feb 13, 2009
1 parent 7a25e16 commit 7279375
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/cmf/pt/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,6 +45,19 @@ def __call__(self, *args, **kwargs):
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)
Expand Down

0 comments on commit 7279375

Please sign in to comment.