Commit b1d7ba24 authored by Hanno Schlichting's avatar Hanno Schlichting

Synced the old pt's with the new code in Five.

parent 0939a8e6
...@@ -17,7 +17,7 @@ from logging import getLogger ...@@ -17,7 +17,7 @@ from logging import getLogger
import AccessControl import AccessControl
from Globals import package_home, InitializeClass, DevelopmentMode from Globals import package_home, InitializeClass, DevelopmentMode
from App.config import getConfiguration from App.config import getConfiguration
from Acquisition import aq_parent, aq_inner from Acquisition import aq_parent, aq_inner, aq_get
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
...@@ -90,7 +90,10 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -90,7 +90,10 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
self.pt_edit( content, guess_type(filename, content)) self.pt_edit( content, guess_type(filename, content))
def pt_getContext(self): def pt_getContext(self):
root = self.getPhysicalRoot() root = None
meth = aq_get(self, 'getPhysicalRoot', None)
if meth is not None:
root = meth()
context = self._getContext() context = self._getContext()
c = {'template': self, c = {'template': self,
'here': context, 'here': context,
...@@ -99,7 +102,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -99,7 +102,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
'nothing': None, 'nothing': None,
'options': {}, 'options': {},
'root': root, 'root': root,
'request': getattr(root, 'REQUEST', None), 'request': aq_get(root, 'REQUEST', None),
'modules': SecureModuleImporter, 'modules': SecureModuleImporter,
} }
return c return c
...@@ -111,12 +114,11 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -111,12 +114,11 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
kw['args'] = args kw['args'] = args
bound_names['options'] = kw bound_names['options'] = kw
try: request = aq_get(self, 'REQUEST', None)
response = self.REQUEST.RESPONSE if request is not None:
response = request.response
if not response.headers.has_key('content-type'): if not response.headers.has_key('content-type'):
response.setHeader('content-type', self.content_type) response.setHeader('content-type', self.content_type)
except AttributeError:
pass
# Execute the template in a new security context. # Execute the template in a new security context.
security = AccessControl.getSecurityManager() security = AccessControl.getSecurityManager()
......
...@@ -17,6 +17,7 @@ $Id$ ...@@ -17,6 +17,7 @@ $Id$
import re import re
import os import os
import Acquisition import Acquisition
from Acquisition import aq_get
from Globals import ImageFile, package_home, InitializeClass from Globals import ImageFile, package_home, InitializeClass
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from Shared.DC.Scripts.Script import Script from Shared.DC.Scripts.Script import Script
...@@ -272,7 +273,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -272,7 +273,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
historyComparisonResults=html_diff(rev1._text, rev2._text) ) historyComparisonResults=html_diff(rev1._text, rev2._text) )
def pt_getContext(self, *args, **kw): def pt_getContext(self, *args, **kw):
root = self.getPhysicalRoot() root = None
meth = aq_get(self, 'getPhysicalRoot', None)
if meth is not None:
root = meth()
context = self._getContext() context = self._getContext()
c = {'template': self, c = {'template': self,
'here': context, 'here': context,
...@@ -281,7 +285,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -281,7 +285,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'nothing': None, 'nothing': None,
'options': {}, 'options': {},
'root': root, 'root': root,
'request': getattr(root, 'REQUEST', None), 'request': aq_get(root, 'REQUEST', None),
'modules': SecureModuleImporter, 'modules': SecureModuleImporter,
} }
return c return c
...@@ -303,12 +307,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -303,12 +307,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
kw['args'] = args kw['args'] = args
bound_names['options'] = kw bound_names['options'] = kw
try: request = aq_get(self, 'REQUEST', None)
response = self.REQUEST.RESPONSE if request is not None:
response = request.response
if not response.headers.has_key('content-type'): if not response.headers.has_key('content-type'):
response.setHeader('content-type', self.content_type) response.setHeader('content-type', self.content_type)
except AttributeError:
pass
security = getSecurityManager() security = getSecurityManager()
bound_names['user'] = security.getUser() bound_names['user'] = security.getUser()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment