[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser - Adder.py:1.1.4.1 Bindings.py:1.1.4.1 Contents.py:1.1.4.1 __init__.py:1.1.4.1 browser.zcml:1.1.4.1 services_bindings.pt:1.1.4.1
Christian Theune
ct@gocept.com
Sat, 25 May 2002 10:03:24 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv26313/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser
Added Files:
Tag: Zope-3x-branch
Adder.py Bindings.py Contents.py __init__.py browser.zcml
services_bindings.pt
Log Message:
Merged the ctheune-services_move-branch to Zope-3x-branch
- Moved Zope.App.OFS.ServiceManager into the Zope.App.OFS.Services package
- Moved Zope.App.OFS.RoleService into the Zope.App.OFS.Services package
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Adder.py ===
##############################################################################
#
# 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: Adder.py,v 1.1.4.1 2002/05/25 14:03:22 ctheune Exp $
"""
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.getContext())
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Bindings.py ===
##############################################################################
#
# 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: Bindings.py,v 1.1.4.1 2002/05/25 14:03:22 ctheune Exp $
"""
from Zope.App.PageTemplate import ViewPageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.ComponentArchitecture.ContextDependent import ContextDependent
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Zope.Proxy.ProxyIntrospection import removeAllProxies
class Bindings(AttributePublisher, ContextDependent):
index = ViewPageTemplateFile('services_bindings.pt')
def getServicesTable(self):
"""
"""
context = self.getContext()
allServices = removeAllProxies(context.getServiceDefinitions())
localServices = removeAllProxies(context.objectItems())
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.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)
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/Contents.py ===
##############################################################################
#
# 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: Contents.py,v 1.1.4.1 2002/05/25 14:03:22 ctheune Exp $
"""
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
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/__init__.py ===
##############################################################################
#
# 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.
#
##############################################################################
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/browser.zcml ===
<zopeConfigure
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'
>
<security:protectClass
name="Zope.App.OFS.Services.ServiceManager.Views.Browser.Contents."
permission_id="Zope.ManageServices"
names="index, listContentInfo, remove, removeObjects, confirmRemoved"/>
<browser:defaultView
name="contents"
for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
factory="Zope.App.OFS.Services.ServiceManager.Views.Browser.Contents." />
<security:protectClass
name="Zope.App.OFS.Services.ServiceManager.Views.Browser.Adder."
permission_id="Zope.ManageServices"
names="index, confirmed, action, listAddableInfo"/>
<browser:view
name="adder"
for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
factory="Zope.App.OFS.Services.ServiceManager.Views.Browser.Adder." />
<security:protectClass
name="Zope.App.OFS.Services.ServiceManager.Views.Browser.Bindings."
permission_id="Zope.ManageServices"
names="index, action, getServicesTable" />
<browser:view
name="bindings"
for="Zope.App.OFS.Services.ServiceManager.IServiceManager."
factory="Zope.App.OFS.Services.ServiceManager.Views.Browser.Bindings." />
<zmi:tabs for="Zope.App.OFS.Services.ServiceManager.ServiceManager.IServiceManager.">
<zmi:tab label="Contents" action="contents;view"/>
<zmi:tab label="Bindings" action="bindings;view"/>
</zmi:tabs>
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Views/Browser/services_bindings.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css"> </style>
</head>
<body metal:fill-slot="body" >
<form action="action" 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>