Log message for revision 68331:
  Merge ajung-zpt-end-game branch.
  

Changed:
  U   Products.Five/trunk/CHANGES.txt
  D   Products.Five/trunk/browser/ProviderExpression.py
  D   Products.Five/trunk/browser/ReuseUtils.py
  D   Products.Five/trunk/browser/TrustedExpression.py
  U   Products.Five/trunk/browser/pagetemplatefile.py
  U   Products.Five/trunk/browser/tests/i18n.pt
  A   Products.Five/trunk/browser/tests/i18n.py
  U   Products.Five/trunk/browser/tests/pages.py
  U   Products.Five/trunk/browser/tests/pages.txt
  U   Products.Five/trunk/browser/tests/test_i18n.py
  U   Products.Five/trunk/browser/tests/test_pages.py
  U   Products.Five/trunk/formlib/formbase.py
  U   Products.Five/trunk/viewlet/directives.txt

-=-
Modified: Products.Five/trunk/CHANGES.txt
===================================================================
--- Products.Five/trunk/CHANGES.txt     2006-05-29 07:08:39 UTC (rev 68330)
+++ Products.Five/trunk/CHANGES.txt     2006-05-29 09:47:23 UTC (rev 68331)
@@ -5,6 +5,13 @@
 Five 1.5c (Unreleased)
 ======================
 
+Restructuring
+-------------
+
+* Zope 2.10+ uses the Zope 3 PageTemplate engine (incl. TAL and
+  TALES).  A bunch of special and magic code in Five has become
+  obsolete with this, some other had to be readjusted.
+
 Bugfixes
 --------
 

Deleted: Products.Five/trunk/browser/ProviderExpression.py
===================================================================
--- Products.Five/trunk/browser/ProviderExpression.py   2006-05-29 07:08:39 UTC 
(rev 68330)
+++ Products.Five/trunk/browser/ProviderExpression.py   2006-05-29 09:47:23 UTC 
(rev 68331)
@@ -1,62 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Provider tales expression registrations
-
-$Id: tales.py 39606 2005-10-25 02:59:26Z srichter $
-"""
-__docformat__ = 'restructuredtext'
-from Products.PageTemplates.Expressions import StringExpr
-from Products.PageTemplates.Expressions import getEngine
-from AccessControl.ZopeGuards import guarded_hasattr
-from AccessControl.ZopeSecurityPolicy import getRoles
-import Products.Five.security
-
-import zope.component
-import zope.schema
-import zope.interface
-from zope.contentprovider import interfaces
-from zope.contentprovider.tales import addTALNamespaceData
-
-_noroles = []
-
-class ProviderExpr(StringExpr):
-    """A provider expression for Zope2 templates.
-    """
-
-    zope.interface.implements(interfaces.ITALESProviderExpression)
-    def __call__(self, econtext):
-        name = StringExpr.__call__(self, econtext)
-        context = econtext.vars['context']
-        request = econtext.vars['request']
-        view = econtext.vars['view']
-
-        # Try to look up the provider.
-        provider = zope.component.queryMultiAdapter(
-            (context, request, view), interfaces.IContentProvider, name)
-
-        # Provide a useful error message, if the provider was not found.
-        if provider is None:
-            raise interfaces.ContentProviderLookupError(name)
-
-        # Insert the data gotten from the context
-        addTALNamespaceData(provider, econtext)
-
-        # Stage 1: Do the state update.
-        provider.update()
-
-        # Stage 2: Render the HTML content.
-        return provider.render()
-
-# Register Provider expression
-getEngine().registerType('provider', ProviderExpr)

Deleted: Products.Five/trunk/browser/ReuseUtils.py
===================================================================
--- Products.Five/trunk/browser/ReuseUtils.py   2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/browser/ReuseUtils.py   2006-05-29 09:47:23 UTC (rev 
68331)
@@ -1,32 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Utils to be reused
-
-$Id$
-"""
-from new import function
-
-def rebindFunction(f,rebindDir=None,**rebinds):
-  '''return *f* with some globals rebound.'''
-  d= {}
-  if rebindDir : d.update(rebindDir)
-  if rebinds: d.update(rebinds)
-  if not d: return f
-  f= getattr(f,'im_func',f)
-  fd= f.func_globals.copy()
-  fd.update(d)
-  nf= function(f.func_code,fd,f.func_name,f.func_defaults or ())
-  nf.__doc__= f.__doc__
-  if f.__dict__ is not None: nf.__dict__= f.__dict__.copy()
-  return nf

Deleted: Products.Five/trunk/browser/TrustedExpression.py
===================================================================
--- Products.Five/trunk/browser/TrustedExpression.py    2006-05-29 07:08:39 UTC 
(rev 68330)
+++ Products.Five/trunk/browser/TrustedExpression.py    2006-05-29 09:47:23 UTC 
(rev 68331)
@@ -1,141 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Trusted expression
-
-$Id$
-"""
-from Products.PageTemplates.PythonExpr import PythonExpr
-from Products.PageTemplates.Expressions import \
-     SubPathExpr, PathExpr, \
-     StringExpr, \
-     getEngine, installHandlers,\
-     SecureModuleImporter
-
-from Products.Five.browser.ProviderExpression import ProviderExpr
-
-from ReuseUtils import rebindFunction
-
-ModuleImporter = SecureModuleImporter
-
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.interface import implements, Interface
-from zope.publisher.browser import setDefaultSkin
-from zope.traversing.namespace import nsParse, namespaceLookup
-from zope.component import queryMultiAdapter
-
-class FakeRequest(dict):
-  implements(IBrowserRequest)
-
-  def getURL(self):
-    return "http://codespeak.net/z3/five";
-
-def trustedTraverse(ob, path, ignored,):
-  if not path: return self
-
-  get = getattr
-  has = hasattr
-  N = None
-  M = rebindFunction # artifical marker
-
-  if isinstance(path, str): path = path.split('/')
-  else: path=list(path)
-
-  REQUEST = get(ob, 'REQUEST', None)
-  if REQUEST is None:
-    REQUEST=FakeRequest()
-    setDefaultSkin(REQUEST)
-  REQUEST['TraversalRequestNameStack'] = path
-  path.reverse()
-  pop=path.pop
-
-  if len(path) > 1 and not path[0]:
-    # Remove trailing slash
-    path.pop(0)
-
-  if not path[-1]:
-    # If the path starts with an empty string, go to the root first.
-    pop()
-    self=ob.getPhysicalRoot()
-
-  object = ob
-  while path:
-    name=pop()
-    __traceback_info__ = path, name
-
-    if name == '..':
-      o=getattr(object, 'aq_parent', M)
-      if o is not M:
-        object=o
-        continue
-
-    if name and name[:1] in '@+':
-      # Process URI segment parameters.
-      ns, nm = nsParse(name)
-      if ns:
-        try:
-          o = namespaceLookup(ns, nm, object, REQUEST).__of__(object)
-        except TraversalError:
-          raise KeyError(name)
-        object = o
-        continue
-
-    t=get(object, '__bobo_traverse__', M)
-    if t is not M: o=t(REQUEST, name)
-    else:
-      o = get(object, name, M)
-      if o is M:
-        try: o = object[name]
-        except (AttributeError, TypeError): # better exception
-            o = queryMultiAdapter((object, REQUEST), Interface, name)
-            if o is not None:
-                o = o.__of__(object)
-            else:
-                raise AttributeError(name)
-    object = o
-
-  return object
-
-
-class SubPathExpr(SubPathExpr):
-  _eval = rebindFunction(SubPathExpr._eval.im_func,
-                         restrictedTraverse=trustedTraverse,
-                         )
-
-class PathExpr(PathExpr):
-  __init__ = rebindFunction(PathExpr.__init__.im_func,
-                            SubPathExpr=SubPathExpr,
-                            )
-
-class StringExpr(StringExpr):
-  __init__ = rebindFunction(StringExpr.__init__.im_func,
-                            PathExpr=PathExpr,
-                            )
-
-
-installHandlers = rebindFunction(installHandlers,
-                                 PathExpr=PathExpr,
-                                 StringExpr=StringExpr,
-                                 PythonExpr=PythonExpr,
-                                 )
-
-def installHandlers2(engine):
-    installHandlers(engine)
-    engine.registerType('provider', ProviderExpr)
-
-_engine=None
-getEngine = rebindFunction(getEngine,
-                           _engine=_engine,
-                           installHandlers=installHandlers2
-                           )
-

Modified: Products.Five/trunk/browser/pagetemplatefile.py
===================================================================
--- Products.Five/trunk/browser/pagetemplatefile.py     2006-05-29 07:08:39 UTC 
(rev 68330)
+++ Products.Five/trunk/browser/pagetemplatefile.py     2006-05-29 09:47:23 UTC 
(rev 68331)
@@ -19,14 +19,16 @@
 
 from Globals import package_home
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.PageTemplates.Expressions import SecureModuleImporter
+from Products.PageTemplates.Expressions import createTrustedZopeEngine
 
 from zope.app.pagetemplate.viewpagetemplatefile import ViewMapper
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 
-from Products.Five.browser.ReuseUtils import rebindFunction
-from Products.Five.browser.TrustedExpression import getEngine, ModuleImporter
+_engine = createTrustedZopeEngine()
+def getEngine():
+    return _engine
 
-
 class ZopeTwoPageTemplateFile(PageTemplateFile):
     """A strange hybrid between Zope 2 and Zope 3 page template.
 
@@ -47,14 +49,8 @@
         basepath, ext = os.path.splitext(self.filename)
         self.__name__ = os.path.basename(basepath)
 
+        super(PageTemplateFile, self).__init__(self.filename, _prefix)
 
-        # required for the ajung-zpt-final-integration branch
-        try:
-            PageTemplateFile.__init__(self, self.filename, _prefix)
-        except:
-            pass
-
-
     def get_path_from_prefix(self, _prefix):
         if isinstance(_prefix, str):
             path = _prefix
@@ -64,12 +60,9 @@
             path = package_home(_prefix)
         return path
 
-    _cook = rebindFunction(PageTemplateFile._cook,
-                           getEngine=getEngine)
+    def pt_getEngine(self):
+        return getEngine()
 
-    pt_render = rebindFunction(PageTemplateFile.pt_render,
-                               getEngine=getEngine)
-
     def pt_getContext(self):
         try:
             root = self.getPhysicalRoot()
@@ -92,7 +85,7 @@
              'options': {},
              'root': root,
              'request': request,
-             'modules': ModuleImporter,
+             'modules': SecureModuleImporter,
              }
         if view is not None:
             c['view'] = view

Modified: Products.Five/trunk/browser/tests/i18n.pt
===================================================================
--- Products.Five/trunk/browser/tests/i18n.pt   2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/browser/tests/i18n.pt   2006-05-29 09:47:23 UTC (rev 
68331)
@@ -8,5 +8,7 @@
 </table>
 <table summary="Explicit summary" title="Explicit title" 
i18n:attributes="summary explicit-summary; title explicit-title" >
 </table>
+<p tal:content="view/this_is_a_message">Text should be inserted here and 
translated automatically</p>
+<p tal:content="view/this_is_a_message" i18n:translate="">Text should be 
inserted here and translated</p>
 </body>
 </html>

Copied: Products.Five/trunk/browser/tests/i18n.py (from rev 68330, 
Products.Five/branches/ajung-zpt-end-game/browser/tests/i18n.py)

Modified: Products.Five/trunk/browser/tests/pages.py
===================================================================
--- Products.Five/trunk/browser/tests/pages.py  2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/browser/tests/pages.py  2006-05-29 09:47:23 UTC (rev 
68331)
@@ -22,35 +22,35 @@
 
     def eagle(self):
         """Docstring"""
-        return "The eagle has landed"
+        return u"The eagle has landed"
 
     def mouse(self):
         """Docstring"""
-        return "The mouse has been eaten by the eagle"
+        return u"The mouse has been eaten by the eagle"
 
 class FancyView(BrowserView):
     """Fancy, fancy stuff"""
 
     def view(self):
-        return "Fancy, fancy"
+        return u"Fancy, fancy"
 
 class CallView(BrowserView):
 
     def __call__(self):
-        return "I was __call__()'ed"
+        return u"I was __call__()'ed"
 
 class CallableNoDocstring:
 
     def __call__(self):
-        return "No docstring"
+        return u"No docstring"
 
 def function_no_docstring(self):
-    return "No docstring"
+    return u"No docstring"
 
 class NoDocstringView(BrowserView):
 
     def method(self):
-        return "No docstring"
+        return u"No docstring"
 
     function = function_no_docstring
 

Modified: Products.Five/trunk/browser/tests/pages.txt
===================================================================
--- Products.Five/trunk/browser/tests/pages.txt 2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/browser/tests/pages.txt 2006-05-29 09:47:23 UTC (rev 
68331)
@@ -35,13 +35,13 @@
   >>> isinstance(view, SimpleView)
   True
   >>> view()
-  'The eagle has landed'
+  u'The eagle has landed'
 
 A browser page that is a Page Template.
 
   >>> view = self.folder.unrestrictedTraverse('testoid/owl.html')
   >>> view()
-  '<p>2</p>\n'
+  u'<p>2</p>\n'
 
 A browser page that is a PageTemplate plus a view class:
 
@@ -49,7 +49,7 @@
   >>> isinstance(view, SimpleView)
   True
   >>> view()
-  '<p>The falcon has taken flight</p>\n'
+  u'<p>The falcon has taken flight</p>\n'
 
 Test pages that have been registered through the cumulative
 <browser:pages> directive:
@@ -58,13 +58,13 @@
   >>> isinstance(view, SimpleView)
   True
   >>> view()
-  'The eagle has landed'
+  u'The eagle has landed'
 
   >>> view = self.folder.unrestrictedTraverse('testoid/mouse-page.txt')
   >>> isinstance(view, SimpleView)
   True
   >>> view()
-  'The mouse has been eaten by the eagle'
+  u'The mouse has been eaten by the eagle'
 
 Zope 2 objects always need a docstring in order to be published.  Five
 adds a docstring automatically if a view method doesn't have it, but
@@ -101,7 +101,7 @@
 
   >>> view = self.folder.unrestrictedTraverse('testoid/seagull.html')
   >>> view()
-  '<html><head><title>bird macro</title></head><body>Color: 
gray</body></html>\n'
+  u'<html><head><title>bird macro</title></head><body>Color: 
gray</body></html>\n'
 
 Test whether old-style direct traversal still works with a
 five:traversable class:
@@ -301,7 +301,7 @@
   ... ''')
   >>> view = self.folder.unrestrictedTraverse('testoid/overridden_view')
   >>> view()
-  'The mouse has been eaten by the eagle'
+  u'The mouse has been eaten by the eagle'
 
 Test traversal to resources from within ZPT pages:
 

Modified: Products.Five/trunk/browser/tests/test_i18n.py
===================================================================
--- Products.Five/trunk/browser/tests/test_i18n.py      2006-05-29 07:08:39 UTC 
(rev 68330)
+++ Products.Five/trunk/browser/tests/test_i18n.py      2006-05-29 09:47:23 UTC 
(rev 68331)
@@ -34,6 +34,7 @@
       ...   <configure package="Products.Five.browser.tests">
       ...     <browser:page
       ...         for="OFS.interfaces.IFolder"
+      ...         class=".i18n.I18nView"
       ...         template="i18n.pt"
       ...         name="i18n.html"
       ...         permission="zope2.View"
@@ -73,6 +74,8 @@
       <table summary="Explizite Zusammenfassung"
              title="Expliziter Titel">
       </table>
+      <p>Dies ist eine Nachricht</p>
+      <p>Dies ist eine Nachricht</p>
       </body>
       </html>
       ...

Modified: Products.Five/trunk/browser/tests/test_pages.py
===================================================================
--- Products.Five/trunk/browser/tests/test_pages.py     2006-05-29 07:08:39 UTC 
(rev 68330)
+++ Products.Five/trunk/browser/tests/test_pages.py     2006-05-29 09:47:23 UTC 
(rev 68331)
@@ -39,7 +39,7 @@
       >>> isinstance(view, SimpleView)
       True
       >>> view()
-      'The eagle has landed'
+      u'The eagle has landed'
 
     This sucks, but we know it
 

Modified: Products.Five/trunk/formlib/formbase.py
===================================================================
--- Products.Five/trunk/formlib/formbase.py     2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/formlib/formbase.py     2006-05-29 09:47:23 UTC (rev 
68331)
@@ -22,7 +22,8 @@
 import zope.lifecycleevent
 from zope import interface
 from zope.formlib import interfaces, form, namedtemplate
-from zope.formlib.i18n import _
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory("zope")
 
 from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
 from Products.Five.browser.decode import processInputs, setPageEncoding

Modified: Products.Five/trunk/viewlet/directives.txt
===================================================================
--- Products.Five/trunk/viewlet/directives.txt  2006-05-29 07:08:39 UTC (rev 
68330)
+++ Products.Five/trunk/viewlet/directives.txt  2006-05-29 09:47:23 UTC (rev 
68331)
@@ -220,7 +220,7 @@
   ...     (content, request, view, manager), interfaces.IViewlet,
   ...     name='weather')
   >>> viewlet.render().strip()
-  '<div>sunny</div>'
+  u'<div>sunny</div>'
   >>> viewlet.extra_string_attributes
   u'can be specified'
 
@@ -253,7 +253,7 @@
   ...     (content, request, view, manager), interfaces.IViewlet,
   ...     name='weather2')
   >>> viewlet().strip()
-  '<div>sunny</div>'
+  u'<div>sunny</div>'
 
 Okay, so the template-driven cases work. But just specifying a class should
 also work:

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to