[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - configure.zcml:1.23.2.3 service.py:1.7.2.3 serviceactivation.pt:1.1.2.3 services.pt:1.3.10.3
Guido van Rossum
guido@python.org
Fri, 7 Mar 2003 15:48:54 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv2055
Modified Files:
Tag: service-config-branch
configure.zcml service.py serviceactivation.pt services.pt
Log Message:
Reimplement service activation as a parameterized view on the service
manager instead of as view on a representative service configuration
object, as Jim suggested. Also cleaned up services.py a bit.
=== Zope3/src/zope/app/browser/services/configure.zcml 1.23.2.2 => 1.23.2.3 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.23.2.2 Fri Mar 7 13:13:21 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml Fri Mar 7 15:48:53 2003
@@ -569,7 +569,7 @@
/>
<page
- for="zope.app.interfaces.services.service.IServiceConfiguration"
+ for="zope.app.interfaces.services.service.IServiceManager"
name="serviceActivation.html"
template="serviceactivation.pt"
class=".service.ServiceActivation"
=== Zope3/src/zope/app/browser/services/service.py 1.7.2.2 => 1.7.2.3 ===
--- Zope3/src/zope/app/browser/services/service.py:1.7.2.2 Thu Mar 6 18:14:18 2003
+++ Zope3/src/zope/app/browser/services/service.py Fri Mar 7 15:48:53 2003
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Adding components for components and configuration
+"""View support for adding and configuring services and other components.
$Id$
"""
@@ -35,8 +35,7 @@
__metaclass__ = type
class ComponentAdding(Adding):
- """Adding component for components
- """
+ """Adding subclass used for configurable components."""
menu_id = "add_component"
@@ -66,7 +65,7 @@
class ServiceAdding(ComponentAdding):
- """Adding a service."""
+ """Adding subclass used for adding services."""
menu_id = "add_service"
@@ -88,14 +87,13 @@
class ConfigurationAdding(Adding):
- """Adding component for configuration
- """
+ """Adding subclass for adding configurations."""
menu_id = "add_configuration"
+
class EditConfiguration(BrowserView):
- """Adding component for service containers
- """
+ """Adding component for service containers."""
menu_id = "add_component"
@@ -104,10 +102,7 @@
self.context = context
def action(self):
- """Perform actions depending on user input.
-
-
- """
+ """Perform actions depending on user input."""
if 'add_submit' in self.request:
self.request.response.redirect('+')
return ''
@@ -138,15 +133,13 @@
return ''
def remove_objects(self, key_list):
- """Remove the directives from the container.
- """
+ """Remove the directives from the container."""
container = getAdapter(self.context, IZopeContainer)
for item in key_list:
del container[item]
def configInfo(self):
- """Render View for each direcitves.
- """
+ """Render View for each directives."""
r = []
for name, directive in self.context.items():
d = ContextWrapper(directive, self.context, name = name)
@@ -156,8 +149,8 @@
return r
-class AddServiceConfiguration:
- """A mixin class."""
+class AddServiceConfiguration(BrowserView):
+ """A view on a service implementation, used by add_svc_config.py."""
def listServiceTypes(self):
@@ -191,9 +184,9 @@
self.request.response.redirect("@@useConfiguration.html")
-class ServiceSummary(BrowserView):
- """A view on the service manager."""
+class ServiceSummary(BrowserView):
+ """A view on the service manager, used by services.pt."""
def listConfiguredServices(self):
names = list(self.context.listConfigurationNames())
@@ -203,61 +196,53 @@
for name in names:
registry = self.context.queryConfigurations(name)
assert registry
- info = registry.info()
- assert info
- representative = info[0]['configuration']
- link1 = str(getView(representative, 'absolute_url', self.request))
-
- component_name = link2 = ""
- if info[0]['active']:
- component = representative.getComponent()
- path = getPhysicalPath(component)
- component_name = "/".join(path[-2:])
- link2 = str(getView(component, 'absolute_url', self.request))
-
- items.append({'name': name,
- 'link1': link1,
- 'component': component_name,
- 'link2': link2,
- })
+ infos = registry.info()
+ assert infos
+ if infos[0]['active']:
+ # XXX This assumes if there is an active one it is the
+ # first one. The implementation promises this, but
+ # the interface does not. However Jim doesn't want
+ # the implementation changed so I guess the interface
+ # docs should be fixed.
+ configobj = infos[0]['configuration']
+ component = configobj.getComponent()
+ url = str(getView(component, 'absolute_url', self.request))
+ else:
+ url = ""
+ items.append({'name': name, 'url': url})
return items
-class ServiceActivation(BrowserView):
- """A view on a service configuration.
+class ServiceActivation(BrowserView):
+ """A view on the service manager, used by serviceactivation.pt.
This really wants to be a view on a configuration registry
containing service configurations, but registries don't have names,
- so we make it a view on a configuration which only serves as a
- representative."""
-
- def serviceName(self):
- return self.context.name
+ so we make it a view on the service manager; the request parameter
+ 'type' determines which service is to be configured."""
def isDisabled(self):
sm = getServiceManager(self.context)
- registry = sm.queryConfigurationsFor(self.context)
- return not registry.active()
+ registry = sm.queryConfigurations(self.request.get('type'))
+ return not (registry and registry.active())
def listRegistry(self):
sm = getServiceManager(self.context)
- registry = sm.queryConfigurationsFor(self.context)
+ registry = sm.queryConfigurations(self.request.get('type'))
+ if not registry:
+ return []
+
result = []
for info in registry.info():
configobj = info['configuration']
component = configobj.getComponent()
path = getPhysicalPath(component)
- name1 = "/".join(path[-2:])
- link1 = str(getView(component, 'absolute_url', self.request))
- link2 = str(getView(configobj, 'absolute_url', self.request))
- item = {'active': info['active'],
- 'id': info['id'],
- 'name1': name1,
- 'link1': link1,
- 'link2': link2,
- }
- result.append(item)
+ info['name'] = "/".join(path[-2:])
+ info['url'] = str(getView(component, 'absolute_url', self.request))
+ info['config'] = str(getView(configobj, 'absolute_url',
+ self.request))
+ result.append(info)
return result
def action(self):
@@ -266,7 +251,9 @@
return ""
sm = getServiceManager(self.context)
- registry = sm.queryConfigurationsFor(self.context)
+ registry = sm.queryConfigurations(self.request.get('type'))
+ if not registry:
+ return "Invalid service type specified"
old_active = registry.active()
if active == "None":
new_active = None
=== Zope3/src/zope/app/browser/services/serviceactivation.pt 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/browser/services/serviceactivation.pt:1.1.2.2 Thu Mar 6 18:14:18 2003
+++ Zope3/src/zope/app/browser/services/serviceactivation.pt Fri Mar 7 15:48:53 2003
@@ -14,12 +14,12 @@
<div metal:fill-slot="body">
<h2>
- <span tal:replace="view/serviceName" />
+ <span tal:replace="request/type|string:No service type specified" />
</h2>
<p tal:content="view/action">Message from action() goes here</p>
- <form action="@@serviceActivation.html" method="POST">
+ <form action="@@serviceActivation.html" method="GET">
<table tal:define="registry view/listRegistry">
<thead>
@@ -33,11 +33,13 @@
tal:attributes="value config/id;
checked config/active" /></td>
<td><a href="foo"
- tal:content="config/name1"
- tal:attributes="href config/link1">Implementation</a></td>
+ tal:content="config/name"
+ tal:attributes="href config/url">Implementation</a>
+ </td>
<td><a href="foo"
tal:content="config/id"
- tal:attributes="href config/link2">Configuration</a></td>
+ tal:attributes="href config/config">Configuration</a>
+ </td>
</tr>
<tr>
@@ -50,6 +52,8 @@
</table>
+ <input type="hidden" name="type" value="Events"
+ tal:attributes="value request/type|nothing" />
<input type="submit" value="Update">
</form>
=== Zope3/src/zope/app/browser/services/services.pt 1.3.10.2 => 1.3.10.3 ===
--- Zope3/src/zope/app/browser/services/services.pt:1.3.10.2 Fri Mar 7 13:36:07 2003
+++ Zope3/src/zope/app/browser/services/services.pt Fri Mar 7 15:48:53 2003
@@ -33,20 +33,20 @@
<tr tal:repeat="reg registries">
<td>
<a href="(link to the active service)"
- tal:condition="reg/component"
- tal:attributes=
- "href string:${reg/link2}/@@SelectedManagementView.html"
+ tal:condition="reg/url"
+ tal:attributes= "href
+ string:${reg/url}/@@SelectedManagementView.html"
tal:content="reg/name">
Foobar (the service type)
</a>
- <span tal:condition="not:reg/component">
+ <span tal:condition="not:reg/url">
<span tal:content="reg/name" />
(disabled)</span>
</td>
<td>
<a href="xxx"
tal:attributes=
- "href string:${reg/link1}/@@serviceActivation.html"
+ "href string:@@serviceActivation.html?type=${reg/name}"
>
(configure)
</a>