[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - viewmeta.py:1.15

Jim Fulton jim@zope.com
Thu, 20 Feb 2003 13:25:29 -0500


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv18984

Modified Files:
	viewmeta.py 
Log Message:
Mix-in classes (class attributes) that asserted interfaces (via an
__implements__ attribute) weren't being handled correctly.  The class
__implements__ was overriding necessary assertions made in other
mix-in classes used to generate the final class.


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.14	Tue Feb 11 21:17:27 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Thu Feb 20 13:24:58 2003
@@ -18,6 +18,10 @@
 
 import os
 
+from zope.interface.implements import implements
+from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.publisher.interfaces.browser import IBrowserView
+
 from zope.exceptions import NotFoundError
 
 from zope.security.proxy import Proxy
@@ -131,20 +135,20 @@
 
     if class_:
 
-        class_ = _context.resolve(class_)
+        original_class = _context.resolve(class_)
 
         if attribute != '__call__':
-            if not hasattr(class_, attribute):
+            if not hasattr(original_class, attribute):
                 raise ConfigurationError(
                     "The provided class doesn't have the specified attribute "
                     )
         if template:
             template = str(_context.path(template))
 
-            class_ = SimpleViewClass(template, bases=(class_, ))
+            new_class = SimpleViewClass(template, bases=(original_class, ))
 
         else:
-            if not hasattr(class_, 'browserDefault'):
+            if not hasattr(original_class, 'browserDefault'):
                 cdict = {
                     'browserDefault':
                     lambda self, request:
@@ -154,10 +158,19 @@
                 cdict = {}
 
             cdict['__page_attribute__'] = attribute
-            class_ = type(class_.__name__, (class_, simple,), cdict)
+            new_class = type(original_class.__name__,
+                          (original_class, simple,),
+                          cdict)
+
+        if hasattr(original_class, '__implements__'):
+            implements(new_class, IBrowserPublisher)
+            implements(new_class, IBrowserPresentation, check=False)
 
     else:
-        class_ = SimpleViewClass(template)
+        new_class = SimpleViewClass(template)
+
+
+
 
     for n in (attribute, 'browserDefault', '__call__', 'publishTraverse'):
         required[n] = permission
@@ -168,14 +181,14 @@
                                required)
     for_ = _handle_for(_context, for_, actions)
 
-    defineChecker(class_, Checker(required))
+    defineChecker(new_class, Checker(required))
 
     actions.append(
         Action(
           discriminator = ('view', for_, name, IBrowserPresentation, layer),
           callable = handler,
           args = ('Views', 'provideView',
-                  for_, name, IBrowserPresentation, [class_], layer),
+                  for_, name, IBrowserPresentation, [new_class], layer),
           )
         )