[Zope-Checkins] SVN: Products.Five/trunk/ Merging alecm-viewlet-support -r67779:67780 to add supports for viewlets on trunk.

Alec Mitchell apm13 at columbia.edu
Mon May 1 18:05:07 EDT 2006


Log message for revision 67811:
  Merging alecm-viewlet-support -r67779:67780 to add supports for viewlets on trunk.
  

Changed:
  U   Products.Five/trunk/README.txt
  A   Products.Five/trunk/browser/ProviderExpression.py
  U   Products.Five/trunk/browser/TrustedExpression.py
  U   Products.Five/trunk/browser/pagetemplatefile.py
  A   Products.Five/trunk/browser/tests/provider.txt
  A   Products.Five/trunk/browser/tests/provider.zcml
  A   Products.Five/trunk/browser/tests/provider_error.pt
  A   Products.Five/trunk/browser/tests/provider_messagebox.pt
  A   Products.Five/trunk/browser/tests/provider_namespace.pt
  A   Products.Five/trunk/browser/tests/provider_namespace2.pt
  A   Products.Five/trunk/browser/tests/test_provider.py
  A   Products.Five/trunk/viewlet/

-=-
Modified: Products.Five/trunk/README.txt
===================================================================
--- Products.Five/trunk/README.txt	2006-05-01 21:03:36 UTC (rev 67810)
+++ Products.Five/trunk/README.txt	2006-05-01 22:05:06 UTC (rev 67811)
@@ -36,6 +36,8 @@
 
 * Zope 2 security declarations in ZCML instead of in Python code.
 
+* Content Providers and Viewlets
+
 Together with another product, CMFonFive, Five can integrate into CMF.
 
 For more information, see ``doc/features.txt``.

Copied: Products.Five/trunk/browser/ProviderExpression.py (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/ProviderExpression.py)

Modified: Products.Five/trunk/browser/TrustedExpression.py
===================================================================
--- Products.Five/trunk/browser/TrustedExpression.py	2006-05-01 21:03:36 UTC (rev 67810)
+++ Products.Five/trunk/browser/TrustedExpression.py	2006-05-01 22:05:06 UTC (rev 67811)
@@ -25,6 +25,8 @@
      getEngine, installHandlers,\
      SecureModuleImporter
 
+from ProviderExpression import ProviderExpr
+
 from ReuseUtils import rebindFunction
 
 ModuleImporter = SecureModuleImporter
@@ -52,7 +54,7 @@
 
   if isinstance(path, str): path = path.split('/')
   else: path=list(path)
-  
+
   REQUEST = get(ob, 'REQUEST', None)
   if REQUEST is None:
     REQUEST=FakeRequest()
@@ -91,7 +93,7 @@
           raise KeyError(name)
         object = o
         continue
-        
+
     t=get(object, '__bobo_traverse__', M)
     if t is not M: o=t(REQUEST, name)
     else:
@@ -123,18 +125,21 @@
   __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=installHandlers
+                           installHandlers=installHandlers2
                            )
 
-
-  

Modified: Products.Five/trunk/browser/pagetemplatefile.py
===================================================================
--- Products.Five/trunk/browser/pagetemplatefile.py	2006-05-01 21:03:36 UTC (rev 67810)
+++ Products.Five/trunk/browser/pagetemplatefile.py	2006-05-01 22:05:06 UTC (rev 67811)
@@ -33,10 +33,10 @@
     Uses Zope 2's engine, but with security disabled and with some
     initialization and API from Zope 3.
     """
-        
+
     def __init__(self, filename, _prefix=None, content_type=None):
         # XXX doesn't use content_type yet
-        
+
         self.ZBindings_edit(self._default_bindings)
 
         path = self.get_path_from_prefix(_prefix)
@@ -53,8 +53,8 @@
             PageTemplateFile.__init__(self, self.filename, _prefix)
         except:
             pass
-        
- 
+
+
     def get_path_from_prefix(self, _prefix):
         if isinstance(_prefix, str):
             path = _prefix
@@ -62,24 +62,24 @@
             if _prefix is None:
                 _prefix = sys._getframe(2).f_globals
             path = package_home(_prefix)
-        return path 
+        return path
 
     _cook = rebindFunction(PageTemplateFile._cook,
                            getEngine=getEngine)
-    
+
     pt_render = rebindFunction(PageTemplateFile.pt_render,
                                getEngine=getEngine)
 
     def _pt_getContext(self):
         try:
             root = self.getPhysicalRoot()
-            view = self._getContext()
         except AttributeError:
-            # self has no attribute getPhysicalRoot. This typically happens 
-            # when the template has no proper acquisition context. 
-            # That also means it has no view.  /regebro
             root = self.context.getPhysicalRoot()
-            view = None
+        # Even if the context isn't a view (when would that be exaclty?),
+        # there shouldn't be any dange in applying a view, because it
+        # won't be used.  However assuming that a lack of getPhysicalRoot
+        # implies a missing view causes problems.
+        view = self._getContext()
 
         here = self.context.aq_inner
 
@@ -94,7 +94,7 @@
              'request': request,
              'modules': ModuleImporter,
              }
-        if view:
+        if view is not None:
             c['view'] = view
             c['views'] = ViewMapper(here, request)
 

Copied: Products.Five/trunk/browser/tests/provider.txt (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider.txt)

Copied: Products.Five/trunk/browser/tests/provider.zcml (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider.zcml)

Copied: Products.Five/trunk/browser/tests/provider_error.pt (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider_error.pt)

Copied: Products.Five/trunk/browser/tests/provider_messagebox.pt (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider_messagebox.pt)

Copied: Products.Five/trunk/browser/tests/provider_namespace.pt (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider_namespace.pt)

Copied: Products.Five/trunk/browser/tests/provider_namespace2.pt (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/provider_namespace2.pt)

Copied: Products.Five/trunk/browser/tests/test_provider.py (from rev 67780, Products.Five/branches/alecm-viewlet-support/browser/tests/test_provider.py)

Copied: Products.Five/trunk/viewlet (from rev 67780, Products.Five/branches/alecm-viewlet-support/viewlet)



More information about the Zope-Checkins mailing list