[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser - Adder.py:1.2 Bindings.py:1.2 Contents.py:1.2 __init__.py:1.2 browser.zcml:1.2 services_bindings.pt:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:44 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser
Added Files:
Adder.py Bindings.py Contents.py __init__.py browser.zcml
services_bindings.pt
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Adder.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Zope.App.OFS.Container.Views.Browser.Adder import ContainerAdder
+from Zope.App.OFS.Services.AddableService import getAddableServices
+
+class Adder(ContainerAdder):
+ """Specialize addable list for service implemenations.
+ """
+ def _listAddables(self):
+ # Override to look up from the service class registry.
+ return getAddableServices(self.context)
+
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Bindings.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.ComponentArchitecture.ContextDependent import ContextDependent
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class Bindings(BrowserView):
+
+ index = ViewPageTemplateFile('services_bindings.pt')
+
+ def getServicesTable(self):
+ """
+ """
+ context = self.context
+ allServices = removeAllProxies(context.getServiceDefinitions())
+ localServices = removeAllProxies(context.items())
+ services = []
+ for serviceName, service in allServices:
+ serviceMap={}
+ availableServices = []
+
+ acquiredOrNone = 'None'
+ bound = context.getBoundService(serviceName)
+
+ if bound is None:
+ try:
+ acquired = context.getService(serviceName)
+ acquiredOrNone = 'Acquired'
+ except ComponentLookupError:
+ pass
+ bound = acquiredOrNone
+
+ availableServices.append(acquiredOrNone)
+
+
+ for localServiceName, localService in localServices:
+ if service.isImplementedBy(localService):
+ availableServices.append(localServiceName)
+
+ serviceMap['name'] = serviceName
+ serviceMap['services'] = availableServices
+ serviceMap['bound'] = bound
+ services.append(serviceMap)
+ return services
+
+ def action(self, boundService, REQUEST):
+ # boundService is a dict service_name:bound_name
+ # the bound_names Acquired and None are special
+
+ context = self.context
+
+ change_count = 0
+
+ for service_name, new_bound_name in boundService.items():
+ # check to see if the bound name has changed
+ current_bound_name = context.getBoundService(service_name)
+ if new_bound_name in ('Acquired', 'None'):
+ new_bound_name = None
+ if current_bound_name != new_bound_name:
+ change_count += 1
+
+ if new_bound_name is None:
+ context.unbindService(service_name)
+ else:
+ context.bindService(service_name, new_bound_name)
+ if change_count:
+ message = "bindings changed"
+ else:
+ message = "no bindings changed"
+ return self.index(REQUEST=REQUEST, message=message)
+
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Contents.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 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.
+#
+##############################################################################
+""" Define view component for service manager contents.
+
+$Id$
+"""
+
+from Zope.App.OFS.Container.Views.Browser.Contents import Contents
+from Zope.App.OFS.Content.Folder.Views.Browser.FolderContents import FolderContents
+from Interface.Implements import flattenInterfaces, objectImplements
+
+class ServiceManagerContents(Contents):
+
+ def _extractContentInfo( self, item ):
+ info = Contents._extractContentInfo(self, item)
+ implements = objectImplements(info['object'])
+ interfaces = flattenInterfaces(implements)
+
+ interface_names = [ x.getName() for x in interfaces
+ if x.getName() != 'Interface' ]
+ info['interfaces'] = interface_names
+
+ return info
+
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 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.
+#
+##############################################################################
+
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/browser.zcml 1.1 => 1.2 ===
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:security='http://namespaces.zope.org/security'
+ xmlns:zmi='http://namespaces.zope.org/zmi'
+ xmlns:browser='http://namespaces.zope.org/browser'
+>
+
+ <browser:defaultView
+ for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
+ name="index.html"
+ />
+
+ <browser:view
+ for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
+ permission="Zope.ManageServices"
+ factory=".Contents."
+ >
+
+ <browser:page name="index.html"
+ attribute="index"
+ />
+ <browser:page name="addServiceManager.html"
+ attribute="addServiceManager"
+ />
+
+ </browser:view>
+
+ <browser:view
+ permission="Zope.ManageServices"
+ for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
+ factory=".Adder.">
+
+ <browser:page name="addForm.html"
+ attribute="index"
+ />
+ <browser:page name="add.html"
+ attribute="action"
+ />
+
+ </browser:view>
+
+ <browser:view
+ permission="Zope.ManageServices"
+ for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
+ factory=".Bindings." >
+
+ <browser:page name="bindings.html"
+ attribute="index"
+ />
+ <browser:page name="changeBindings.html"
+ attribute="action"
+ />
+
+ </browser:view>
+
+
+ <zmi:tabs
+ for="Zope.App.OFS.Services.ServiceManager.ServiceManager.IServiceManager.">
+ <zmi:tab label="Contents" action="@@index.html"/>
+ <zmi:tab label="Bindings" action="@@bindings.html"/>
+ </zmi:tabs>
+
+</zopeConfigure>
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/services_bindings.pt 1.1 => 1.2 ===
+ <head>
+ <style metal:fill-slot="headers" type="text/css"> </style>
+ </head>
+ <body metal:fill-slot="body" >
+ <form action="changeBindings.html" method="post">
+ <table>
+ <tr><th>Name</th><th>boundService</th></tr>
+ <tr tal:repeat="service view/getServicesTable">
+ <td tal:content="service/name">Name</td>
+ <td>
+ <select tal:attributes="name string:boundService.${service/name}:record">
+ <option tal:repeat="available service/services"
+ tal:attributes="value available;
+ selected python:service['bound'] == available or None"
+ tal:content="available">Service</option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <input type=submit value="change bindings">
+ </form>
+ </body>
+</html>