[Zope3-checkins] CVS: Zope3/src/zope/app/presentation - presentation.py:1.18.2.1

Martijn Faassen m.faassen at vet.uu.nl
Tue May 11 05:10:56 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/presentation
In directory cvs.zope.org:/tmp/cvs-serv20906/src/zope/app/presentation

Modified Files:
      Tag: faassen-interfaces-branch
	presentation.py 
Log Message:
Sync up with changes in HEAD (so I can generate up to date patch file).


=== Zope3/src/zope/app/presentation/presentation.py 1.18 => 1.18.2.1 ===
--- Zope3/src/zope/app/presentation/presentation.py:1.18	Sat Apr 24 19:17:57 2004
+++ Zope3/src/zope/app/presentation/presentation.py	Tue May 11 05:10:22 2004
@@ -16,11 +16,11 @@
 $Id$
 """
 import persistent.dict
-from zope.app import zapi
-from zope.app.i18n import ZopeMessageIDFactory as _
+
+from zope.interface import implements, providedBy, Interface, Attribute
+from zope.security.checker import NamesChecker, ProxyFactory
 from zope.component.presentation import IDefaultViewName
 from zope.component.presentation import PresentationRegistration
-from zope.security.checker import NamesChecker, ProxyFactory
 
 import zope.app.component.nextservice
 import zope.app.container.contained
@@ -29,14 +29,15 @@
 import zope.app.site.interfaces
 import zope.app.adapter
 import zope.app.interface.interfaces
-import zope.app.adapter
 import zope.component.interfaces
 import zope.component.presentation
 import zope.configuration.exceptions
-import zope.interface
 import zope.proxy
 import zope.publisher.interfaces.browser
 import zope.schema
+
+from zope.app import zapi
+from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.dependable.interfaces import IDependable, DependencyError
 from zope.app.registration.interfaces import IRegistered
 
@@ -48,7 +49,7 @@
     zope.app.adapter.LocalAdapterBasedService,
     ):
 
-    zope.interface.implements(
+    implements(
         zope.component.interfaces.IPresentationService,
         zope.app.site.interfaces.ISimpleService,
         zope.app.registration.interfaces.IRegistry,
@@ -88,7 +89,7 @@
         return self.delegate.queryLayer(name)
 
     def queryView(self, object, name, request,
-                  providing=zope.interface.Interface, default=None):
+                  providing=Interface, default=None):
         """Look for a named view for a given object and request
 
         The request must implement IPresentationRequest.
@@ -113,8 +114,7 @@
                 return r
         return default
 
-
-    def queryResource(self, name, request, providing=zope.interface.Interface,
+    def queryResource(self, name, request, providing=Interface,
                       default=None):
         """Look up a named resource for a given request
         
@@ -142,7 +142,7 @@
         return default
 
     def queryMultiView(self, objects, request,
-                       providing=zope.interface.Interface, name='',
+                       providing=Interface, name='',
                        default=None):
         """Adapt the given objects and request
 
@@ -181,13 +181,12 @@
                 layer = self.delegate.queryLayer(layername)
             if layer is None:
                 raise ValueError("Bad layer", layer)
-            r = layer.lookup(map(zope.interface.providedBy, objects),
+            r = layer.lookup(map(providedBy, objects),
                              IDefaultViewName)
             if r is not None:
                 return r
         return default
 
-
     def queryRegistrationsFor(self, registration, default=None):
         layername = registration.layer
         layer = self.layers.get(layername)
@@ -238,15 +237,12 @@
                 if registration.required[0] in iro:
                     # Not using an adapter here, since it would be just
                     # overhead.
-                    yield GlobalViewRegistration(registration)
-                    
-                
+                    yield GlobalViewRegistration(registration)                
 
-class GlobalViewRegistration:
+class GlobalViewRegistration(object):
     """Registrations representing global view service thingies."""
 
-    zope.interface.implements(
-        zope.app.registration.interfaces.IRegistration)
+    implements(zope.app.registration.interfaces.IRegistration)
 
     serviceType = zapi.servicenames.Presentation
     status = zope.app.registration.interfaces.ActiveStatus
@@ -279,7 +275,6 @@
         # XXX This should report the ZCML that it came from.
         return _("Registered by ZCML")
 
-
 class LocalLayer(
     zope.app.adapter.LocalAdapterRegistry,
     zope.component.presentation.Layer,
@@ -292,7 +287,6 @@
         self.__parent__ = parent
         self.__name__ = name
 
-
 class IViewRegistration(zope.app.adapter.IAdapterRegistration):
 
     required = zope.schema.Choice(
@@ -321,12 +315,10 @@
         )
 
 class ViewRegistration(zope.app.registration.registration.SimpleRegistration):
-
-    zope.interface.implements(IViewRegistration)
+    implements(IViewRegistration)
 
     serviceType = zapi.servicenames.Presentation
-
-    provided = zope.interface.Interface
+    provided = Interface
 
     # For usageSummary(); subclass may override
     _what = _("view-component", 'View')
@@ -348,7 +340,7 @@
             ifname = self.required.getName()
 
         pname = self.requestType.getName()
-        summary = _("${view_name} for ${pname} {what} {iface_name}")
+        summary = _("${view_name} for ${pname} ${what} ${iface_name}")
         if self.layer and self.layer != "default":
             summary = _(
                 "${view_name} for ${pname} ${what} ${iface_name}"
@@ -387,7 +379,7 @@
         required = False,
         )
 
-    factory = zope.interface.Attribute(
+    factory = Attribute(
         _("Factory to be called to construct an adapter")
         )
 
@@ -398,8 +390,7 @@
         """
 
 class PageRegistration(ViewRegistration):
-
-    zope.interface.implements(IPageRegistration)
+    implements(IPageRegistration)
 
     # We only care about browser pages
     requestType = zope.publisher.interfaces.browser.IBrowserRequest
@@ -459,9 +450,7 @@
                 (self.required, self.name))
 
     def factory(self):
-
         self.validate()
-
         sm = zapi.getServiceManager(self)
 
         if self.factoryName:
@@ -470,13 +459,9 @@
         else:
             class_  = DefaultClass
 
-
-
         if self.attribute:
             return AttrViewFactory(class_, self.attribute)
-
         else:
-
             if self.template[0]=='/':
                 # This is needed because we need to do an unrestricted zapi.
                 # traverse
@@ -489,10 +474,8 @@
 
     factory = property(factory)
 
-
-class PageRegistrationAddSubscriber:
-
-    zope.interface.implements(zope.app.event.interfaces.ISubscriber)
+class PageRegistrationAddSubscriber(object):
+    implements(zope.app.event.interfaces.ISubscriber)
 
     def __init__(self, page_registration, event):
         self.page_registration = page_registration
@@ -507,9 +490,8 @@
             dependents.addDependent(objectpath)
 
 
-class PageRegistrationRemoveSubscriber:
-
-    zope.interface.implements(zope.app.event.interfaces.ISubscriber)
+class PageRegistrationRemoveSubscriber(object):
+    implements(zope.app.event.interfaces.ISubscriber)
 
     def __init__(self, page_registration, event):
         self.page_registration = page_registration
@@ -523,7 +505,7 @@
             objectpath = zapi.getPath(self)
             dependents.removeDependent(objectpath)
 
-
+#XXX can't make new-style class b/c of unpickling error...
 class TemplateViewFactory:
 
     def __init__(self, cls, template, permission):
@@ -534,7 +516,7 @@
         template = BoundTemplate(self.template, self.cls(object, request))
         return ProxyFactory(template, checker)
 
-class AttrViewFactory:
+class AttrViewFactory(object):
 
     def __init__(self, cls, attr):
         self.cls, self.attr = cls, attr
@@ -543,13 +525,13 @@
         attr = getattr(self.cls(object, request), self.attr)
         return ProxyFactory(attr)
 
-class DefaultClass:
+class DefaultClass(object):
 
     def __init__(self, context, request):
         self.context = context
         self.request = request
 
-class BoundTemplate:
+class BoundTemplate(object):
 
     def __init__(self, template, view):
         self.template = template




More information about the Zope3-Checkins mailing list