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
import AccessControl
from Globals import package_home, InitializeClass, DevelopmentMode
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 OFS.SimpleItem import SimpleItem
from OFS.Traversable import Traversable
......@@ -90,7 +90,10 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
self.pt_edit( content, guess_type(filename, content))
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()
c = {'template': self,
'here': context,
......@@ -99,7 +102,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
'nothing': None,
'options': {},
'root': root,
'request': getattr(root, 'REQUEST', None),
'request': aq_get(root, 'REQUEST', None),
'modules': SecureModuleImporter,
}
return c
......@@ -111,12 +114,11 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
kw['args'] = args
bound_names['options'] = kw
try:
response = self.REQUEST.RESPONSE
request = aq_get(self, 'REQUEST', None)
if request is not None:
response = request.response
if not response.headers.has_key('content-type'):
response.setHeader('content-type', self.content_type)
except AttributeError:
pass
# Execute the template in a new security context.
security = AccessControl.getSecurityManager()
......
......@@ -17,6 +17,7 @@ $Id$
import re
import os
import Acquisition
from Acquisition import aq_get
from Globals import ImageFile, package_home, InitializeClass
from DateTime.DateTime import DateTime
from Shared.DC.Scripts.Script import Script
......@@ -272,7 +273,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
historyComparisonResults=html_diff(rev1._text, rev2._text) )
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()
c = {'template': self,
'here': context,
......@@ -281,7 +285,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'nothing': None,
'options': {},
'root': root,
'request': getattr(root, 'REQUEST', None),
'request': aq_get(root, 'REQUEST', None),
'modules': SecureModuleImporter,
}
return c
......@@ -303,12 +307,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
kw['args'] = args
bound_names['options'] = kw
try:
response = self.REQUEST.RESPONSE
request = aq_get(self, 'REQUEST', None)
if request is not None:
response = request.response
if not response.headers.has_key('content-type'):
response.setHeader('content-type', self.content_type)
except AttributeError:
pass
security = getSecurityManager()
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