[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - interfaces.py:1.2 viewpackage.py:1.2 ServiceManager.py:1.17 configure.zcml:1.10

Jim Fulton jim@zope.com
Thu, 19 Dec 2002 15:38:55 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv26340/lib/python/Zope/App/OFS/Services/ServiceManager

Modified Files:
	ServiceManager.py configure.zcml 
Added Files:
	interfaces.py viewpackage.py 
Log Message:
Merged changes made by Albertas and Jim from the AdapterAndView-branch
branch:

- Added TTW adapter service

  Todo: 

    o Named adapters

    o Getting classes in persistent modules working so we can actually
      create TTW adapters.

- Added TTW view service

  o View service

  o View configurations
 
    For configuting views from view factories

  o Page configurations 

    For configuring views based on templates (and optional classes)

  o View (sub)packages.  These get added to packages. You configure
    them with default configuration info and then add page templates
    to them. Added page temlates are automatically added as views with
    the same name.




=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/interfaces.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 15:38:55 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/interfaces.py	Thu Dec 19 15:38:25 2002
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+# 
+##############################################################################
+"""View package.
+
+$Id$
+"""
+__metaclass__ = type
+
+from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
+from Interface import Interface
+from Zope.App.ComponentArchitecture.InterfaceField import InterfaceField
+from Zope.Schema import BytesLine
+from Zope.ComponentArchitecture.IPresentation import IPresentation
+from Zope.App.OFS.Container.IContainer import IContainer
+
+class IViewPackageInfo(Interface):
+
+    forInterface = InterfaceField(
+        title = u"For interface",
+        description = u"The interface of the objects being viewed",
+        required = True,
+        )
+
+    presentationType = InterfaceField(
+        title = u"Presentation type",
+        description = u"The presentation type of a view",
+        required = True,
+        type = IPresentation,
+        default = IBrowserPresentation,
+        )
+
+    factoryName = BytesLine(
+        title=u"The dotted name of a factory for creating the view",
+        required = True,
+        )
+
+    layer = BytesLine(
+        title = u"Layer",
+        description = u"The skin layer the view is registered for",
+        required = False,
+        min_length = 1,
+        default = "default",
+        )
+
+class IViewPackage(IViewPackageInfo,  IContainer):
+    """Sub-packages that contain templates that are registered as views
+    """


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/viewpackage.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 15:38:55 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/viewpackage.py	Thu Dec 19 15:38:25 2002
@@ -0,0 +1,75 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+# 
+##############################################################################
+"""View package.
+
+$Id$
+"""
+__metaclass__ = type
+
+from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
+from Zope.App.OFS.Services.interfaces import IZPTTemplate
+from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
+from Zope.App.Traversing import getPhysicalPathString, traverse
+from Zope.Proxy.ContextWrapper import getItem, getAttr
+from Zope.ContextWrapper import ContextMethod
+from Zope.App.OFS.Services.ConfigurationInterfaces import Active
+from Zope.App.OFS.Services.ServiceManager.ConfigurationManager \
+     import ConfigurationManager
+from Zope.App.OFS.Services.Configuration import ConfigurationStatusProperty
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+from Zope.App.OFS.Services.view import PageConfiguration
+from interfaces import IViewPackage
+
+class ViewPackage(BTreeContainer):
+
+    __implements__ = IViewPackage
+
+
+    presentationType = IBrowserPresentation
+    layer = "default"
+    description = ''
+    title = ''
+
+    def __init__(self):
+        super(ViewPackage, self).__init__()
+        super(ViewPackage, self).setObject('configure', ConfigurationManager())
+
+    def setObject(self, name, object):
+        if not IZPTTemplate.isImplementedBy(object):
+            raise TypeError("Can only add packages")
+        
+        # super() does not work on a context wrapped instance
+        base = removeAllProxies(self)
+
+        name = super(ViewPackage, base).setObject(name, object)
+        template = getItem(self, name)
+        template = getPhysicalPathString(template)
+        config = PageConfiguration(self.forInterface, name,
+                                   self.presentationType,
+                                   self.factoryName, template,
+                                   self.layer)
+        configure = traverse(self, 'configure')
+        id = configure.setObject('', config)
+        config = getItem(configure, id)
+        config.status = Active
+        return name
+
+    setObject = ContextMethod(setObject)
+
+    def activated(self):
+        "See Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration"
+
+    def deactivated(self):
+        "See Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration"
+


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py 1.16 => 1.17 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py:1.16	Wed Dec 18 15:23:05 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py	Thu Dec 19 15:38:24 2002
@@ -145,11 +145,12 @@
         if key == 'Packages':
             return wrapped_self.Packages
 
-        directives = wrapped_self.queryConfigurations(key)
-        if directives and directives[0] is not None:
-            return wrapped_self.queryService(key, default)
+        service = wrapped_self.queryActiveComponent(key)
+        if service is None:
+            return default
+
+        return service
 
-        return default
     get = ContextMethod(get)
 
     def __contains__(self, key):


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml 1.9 => 1.10 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml:1.9	Thu Dec 12 06:32:32 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml	Thu Dec 19 15:38:25 2002
@@ -23,6 +23,7 @@
     <require
         permission="Zope.ManageServices"
         interface=".IComponentManager." />
+    <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
 
   </content>
 
@@ -33,10 +34,15 @@
     <require
         permission="Zope.ManageServices"
         interface="Zope.App.OFS.Container.IContainer.IWriteContainer" />
+    <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
 
   </content>
 
    <content class=".ConfigurationManager.">
+    <factory
+        id = "Zope.App.OFS.Services.ServiceManager.ConfigurationManager"
+        permission = "Zope.ManageServices"
+        title = "Configuration Manager" />
     <require
         permission="Zope.View"
         interface="Zope.App.OFS.Container.IContainer.IReadContainer" />
@@ -49,10 +55,7 @@
     <require
         permission="Zope.ManageServices"
         interface="Zope.App.OFS.Container.IDeleteNotifiable." />
-    <factory
-        id = "Zope.App.OFS.Services.ServiceManager.ConfigurationManager"
-        permission = "Zope.ManageServices"
-        title = "Configuration Manager" />
+    <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
   </content>
 
   <content class=".Module.Manager.">
@@ -82,6 +85,27 @@
 
   </content>
 
+  <content class=".viewpackage.ViewPackage">
+    <factory 
+        id = "Zope.App.OFS.Services.ServiceManager.viewpackage.ViewPackage" 
+	permission = "Zope.ManageServices"
+	title = "View Package" />
+    <require
+        permission="Zope.View"
+        interface="Zope.App.OFS.Container.IContainer.IReadContainer" />
+    <require
+        permission="Zope.ManageServices"
+        interface="Zope.App.OFS.Container.IContainer.IWriteContainer"
+        set_schema=".interfaces.IViewPackageInfo"
+        />
+    <require
+        permission="Zope.ManageServices"
+        interface=".interfaces.IViewPackageInfo"
+        />
+    <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
+  </content>
+
+  
   <include package="Zope.App.OFS.Services.ServiceManager.Browser" />
 
 </zopeConfigure>