[Zope-Checkins] SVN: Zope/branches/philikon-aq/lib/python/Products/PageTemplates/ Synced the old pt's with the new code in Five.

Hanno Schlichting plone at hannosch.info
Sun Jul 29 06:49:46 EDT 2007


Log message for revision 78452:
  Synced the old pt's with the new code in Five.
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/Products/PageTemplates/PageTemplateFile.py
  U   Zope/branches/philikon-aq/lib/python/Products/PageTemplates/ZopePageTemplate.py

-=-
Modified: Zope/branches/philikon-aq/lib/python/Products/PageTemplates/PageTemplateFile.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/PageTemplates/PageTemplateFile.py	2007-07-29 01:48:18 UTC (rev 78451)
+++ Zope/branches/philikon-aq/lib/python/Products/PageTemplates/PageTemplateFile.py	2007-07-29 10:49:45 UTC (rev 78452)
@@ -17,7 +17,7 @@
 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 @@
         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 @@
              'nothing': None,
              'options': {},
              'root': root,
-             'request': getattr(root, 'REQUEST', None),
+             'request': aq_get(root, 'REQUEST', None),
              'modules': SecureModuleImporter,
              }
         return c
@@ -111,12 +114,11 @@
             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()

Modified: Zope/branches/philikon-aq/lib/python/Products/PageTemplates/ZopePageTemplate.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/PageTemplates/ZopePageTemplate.py	2007-07-29 01:48:18 UTC (rev 78451)
+++ Zope/branches/philikon-aq/lib/python/Products/PageTemplates/ZopePageTemplate.py	2007-07-29 10:49:45 UTC (rev 78452)
@@ -17,6 +17,7 @@
 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 @@
             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 @@
              'nothing': None,
              'options': {},
              'root': root,
-             'request': getattr(root, 'REQUEST', None),
+             'request': aq_get(root, 'REQUEST', None),
              'modules': SecureModuleImporter,
              }
         return c
@@ -303,12 +307,11 @@
             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()



More information about the Zope-Checkins mailing list