[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/service -
__init__.py:1.16 services.pt:1.4
Richard Jones
richard at commonground.com.au
Mon Feb 9 00:06:22 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/browser/services/service
In directory cvs.zope.org:/tmp/cvs-serv18146/app/browser/services/service
Modified Files:
__init__.py services.pt
Log Message:
list all services available to a site in the Services tab
=== Zope3/src/zope/app/browser/services/service/__init__.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/browser/services/service/__init__.py:1.15 Sun Feb 8 22:54:06 2004
+++ Zope3/src/zope/app/browser/services/service/__init__.py Mon Feb 9 00:06:21 2004
@@ -29,8 +29,10 @@
from zope.app.interfaces.services.utility import ILocalUtility
from zope.app.services.service import ServiceRegistration
from zope.publisher.browser import BrowserView
-from zope.app.interfaces.services.service import ISite
+from zope.app.interfaces.services.service import ISite, ISiteManager
from zope.app.services.service import SiteManager
+from zope.app.component.nextservice import getNextServiceManager
+from zope.component.service import IGlobalServiceManager
class ComponentAdding(Adding):
"""Adding subclass used for registerable components."""
@@ -312,25 +314,59 @@
return s
def listConfiguredServices(self):
- names = list(self.context.listRegistrationNames())
- names.sort()
-
- items = []
- for name in names:
- registry = self.context.queryRegistrations(name)
- assert registry
- infos = [info for info in registry.info() if info['active']]
- if infos:
- configobj = infos[0]['registration']
- component = configobj.getComponent()
- url = str(
- zapi.getView(component, 'absolute_url', self.request))
- else:
- url = ""
- items.append({'name': name, 'url': url})
-
- return items
+ return gatherConfiguredServices(self.context, self.request)
+def gatherConfiguredServices(sm, request, items=None):
+ """Find all s/service/site managers up to the root and gather info
+ about their services.
+ """
+ if items is None:
+ items = {}
+ manageable = True # is manageable from this View (easily)
+ # make sure no-one tries to use this starting at the global service
+ # manager
+ assert ISiteManager.isImplementedBy(sm)
+ else:
+ manageable = False
+
+ if IGlobalServiceManager.isImplementedBy(sm):
+ # global service manager
+ names = []
+ for type_name, interface in sm.getServiceDefinitions():
+ if items.has_key(type_name):
+ # a child has already supplied one of these
+ continue
+ if sm.queryService(type_name) is not None:
+ names.append(type_name)
+ items[type_name] = {'name': type_name, 'url': '',
+ 'manageable': False, 'parent': 'global'}
+ return
+
+ for name in sm.listRegistrationNames():
+ if items.has_key(name):
+ # a child has already supplied one of these
+ continue
+
+ registry = sm.queryRegistrations(name)
+ assert registry
+ infos = [info for info in registry.info() if info['active']]
+ if infos:
+ configobj = infos[0]['registration']
+ component = configobj.getComponent()
+ url = str(
+ zapi.getView(component, 'absolute_url', request))
+ else:
+ url = ""
+ items[name] = {'name': name, 'url': url, 'manageable': manageable,
+ 'parent': 'parent'}
+
+ # look for more
+ gatherConfiguredServices(getNextServiceManager(sm), request, items)
+
+ # make it a list and sort by name
+ items = items.values()
+ items.sort(lambda a,b:cmp(a['name'], b['name']))
+ return items
class ServiceActivation(BrowserView):
"""A view on the service manager, used by serviceactivation.pt.
=== Zope3/src/zope/app/browser/services/service/services.pt 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/services/service/services.pt:1.3 Sat Feb 7 21:09:28 2004
+++ Zope3/src/zope/app/browser/services/service/services.pt Mon Feb 9 00:06:21 2004
@@ -31,25 +31,32 @@
<table>
<tr tal:repeat="reg registries">
- <td><input type="checkbox" name="selected:list"
- tal:attributes="value reg/name" /></td>
+ <td><input tal:condition="reg/manageable" type="checkbox"
+ name="selected:list" tal:attributes="value reg/name" />
+ </td>
<td>
+ <tal:block condition="reg/manageable">
<a href="(link to the active service)"
tal:condition="reg/url"
tal:attributes= "href reg/url"
tal:content="reg/name">
Foobar (the service type)
</a>
- <span tal:condition="not:reg/url">
- <span tal:content="reg/name" />(disabled)</span>
+ <span tal:condition="not:reg/url"
+ tal:replace="string:${reg/name} (disabled)" />
+ </tal:block>
+ <span tal:condition="not:reg/manageable" tal:replace="reg/name" />
</td>
<td>
+ <tal:block condition="reg/manageable">
<a href="xxx"
- tal:attributes=
- "href string:@@serviceActivation.html?type=${reg/name}"
+ tal:condition="reg/manageable"
+ tal:attributes="href string:@@serviceActivation.html?type=${reg/name}"
i18n:translate="">
(change registration)
</a>
+ </tal:block>
+ <span tal:condition="not:reg/manageable" tal:replace="reg/parent" />
</td>
</tr>
</table>
More information about the Zope3-Checkins
mailing list