[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser - Bindings.py:1.1.2.2 services_bindings.pt:1.1.2.2
Steve Alexander
steve@cat-box.net
Mon, 4 Mar 2002 18:52:17 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv1579/Views/Browser
Modified Files:
Tag: Zope-3x-branch
Bindings.py services_bindings.pt
Log Message:
Working TTW service manager + tests.
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/Bindings.py 1.1.2.1 => 1.1.2.2 ===
acquiredOrNone = 'None'
bound = context.getBoundService(serviceName)
+
if bound is None:
# Because ServiceManager impliments the same interface as
# the global service manager, it needs to take an "object"
@@ -45,15 +46,13 @@
if acquired:
acquiredOrNone = 'Acquired'
bound = acquiredOrNone
-
-
+
availableServices.append(acquiredOrNone)
-
for localServiceName, localService in localServices:
if service.isImplementedBy(localService):
- availableServices.append(localService)
+ availableServices.append(localServiceName)
serviceMap['name'] = serviceName
serviceMap['services'] = availableServices
@@ -61,7 +60,29 @@
services.append(serviceMap)
return services
- def action(self):
- pass
+ def action(self, boundService, REQUEST):
+ # boundService is a dict service_name:bound_name
+ # the bound_names Acquired and None are special
+
+ context = self.getContext()
+
+ 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/ServiceManager/Views/Browser/services_bindings.pt 1.1.2.1 => 1.1.2.2 ===
<style metal:fill-slot="headers" type="text/css"> </style>
</head>
- <body metal:fill-slot="main" >
+ <body metal:fill-slot="body" >
+ <form action="action" method="post">
<table>
+ <tr><th>Name</th><th>boundService</th></tr>
<tr tal:repeat="service container/getServicesTable">
<td tal:content="service/name">Name</td>
<td>
- <select name="boundService">
+ <select tal:attributes="name string:boundService.${service/name}:record">
<option tal:repeat="available service/services"
- tal:attributes="value available; selected python:service['bound'] == available | nothing"
+ 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>
\ No newline at end of file
+</html>