[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser - Adder.py:1.1.2.1 Bindings.py:1.1.2.1 Contents.py:1.1.2.1 __init__.py:1.1.2.1 browser.zcml:1.1.2.1 main.pt:1.1.2.1 services_bindings.pt:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 4 Mar 2002 11:48:20 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv12773/ServiceManager/Views/Browser
Added Files:
Tag: Zope-3x-branch
Adder.py Bindings.py Contents.py __init__.py browser.zcml
main.pt services_bindings.pt
Log Message:
Moved ServiceManager code to OFS, which is just a logical place for
standard/default TTW object implementations.
Refactored SecurityManager to use container framework.
=== Added File Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/Adder.py ===
##############################################################################
#
# Copyright (c) 2001 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.2.1 2002/03/04 16:48:19 jim Exp $
"""
from Zope.App.OFS.Container.Views.Browser.Adder import ContainerAdder
from Zope.App.ZMI.Addable import ServiceAddables
class Adder(ContainerAdder):
"""Specialize addable list for service implemenations.
"""
def _listAddables(self):
# Override to look up from the service class registry.
return ServiceAddables.getAddables( self.getContext() )
=== Added File Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/Bindings.py ===
##############################################################################
#
# Copyright (c) 2001 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.2.1 2002/03/04 16:48:19 jim Exp $
"""
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.ComponentArchitecture.ContextDependent import ContextDependent
class Bindings(AttributePublisher, ContextDependent):
index = PageTemplateFile('services_bindings.pt')
def getServicesTable(self):
"""
"""
context = self.getContext()
allServices = context.getServiceDefinitions()
localServices = context.objectItems()
services = []
for serviceName, service in allServices:
serviceMap={}
availableServices = []
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"
# which is the location to start the search for ServiceManagers
# if it's own lookup fails. By default, this is "self"
acquired = context.getService(self, serviceName)
if acquired:
acquiredOrNone = 'Acquired'
bound = acquiredOrNone
availableServices.append(acquiredOrNone)
for localServiceName, localService in localServices:
if service.isImplementedBy(localService):
availableServices.append(localService)
serviceMap['name'] = serviceName
serviceMap['services'] = availableServices
serviceMap['bound'] = bound
services.append(serviceMap)
return services
def action(self):
pass
=== Added File Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/Contents.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.2.1 2002/03/04 16:48:19 jim Exp $
"""
from Zope.App.OFS.Container.Views.Browser.Contents import Contents
from Zope.App.OFS.Folder.FolderContents import FolderContents
from Interface.Util 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/ServiceManager/Views/Browser/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/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.ServiceManager.Views.Browser.Contents."
permission_id="Zope.ManageServices"
methods="index, listContentInfo, remove, removeObjects, confirmRemoved"/>
<browser:defaultView
name="contents"
for="Zope.App.OFS.ServiceManager.IServiceManager."
factory="Zope.App.OFS.ServiceManager.Views.Browser.Contents." />
<security:protectClass
name="Zope.App.OFS.ServiceManager.Views.Browser.Adder."
permission_id="Zope.ManageServices"
methods="index, confirmed, action, listAddableInfo"/>
<browser:view
name="adder"
for="Zope.App.OFS.ServiceManager.IServiceManager."
factory="Zope.App.OFS.ServiceManager.Views.Browser.Adder." />
<security:protectClass
name="Zope.App.OFS.ServiceManager.Views.Browser.Bindings."
permission_id="Zope.ManageServices"
methods="index, action, getServicesTable" />
<browser:view
name="bindings"
for="Zope.App.OFS.ServiceManager.IServiceManager."
factory="Zope.App.OFS.ServiceManager.Views.Browser.Bindings." />
<zmi:tabs for="Zope.App.OFS.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/ServiceManager/Views/Browser/main.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
<!--
.ContentListing {
width: 100%;
}
.ContentIcon {
width: 20px;
}
.ContentTitle {
text-align: left;
}
.ContentInterface {
text-align: left;
}
-->
</style>
</head>
<body>
<div metal:fill-slot="body">
<form action="contents;view" method="get">
<table class="ContentListing">
<caption>Service Manager Contents <a href="adder;view"> Add... </a> </caption>
<tbody>
<tr>
<td> </td>
<td class="ContentIcon"><br /> </td>
<th class="ContentTitle">Title</th>
<th class="ContentInterface">Interfaces</th>
</tr>
<!--
** listContentInfo returns a sequence of mappings, containing:
** 'id' : the ID of the contained within the container
** 'url' : the absolute URL of the contained object
** 'title' : the title of the contained object
** 'icon' : the absolute URL of the icon, for the contained object
(may be None)
** 'interfaces' : the interfaces that this service implements
-->
<tr tal:repeat="info container/listContentInfo">
<td class="ContentSelect" valign="top">
<input type="checkbox" name="ids:list" value="id"
tal:attributes="value info/id" />
</td>
<td class="ContentIcon" valign="top">
<img alt="Service A Icon" src="../../ZMI/www/folder_icon.gif"
tal:condition="info/url"
tal:attributes="src info/url" />
</td>
<td class="ContentTitle" valign="top">
<a href="service_a_id"
tal:attributes="href info/url"
tal:content="info/title"
>Service A Title or ID here</a>
</td>
<td class="ContentInterface">
<div tal:repeat="interface info/interfaces">
<span tal:replace="interface">Interface Name</span><br/>
</div>
</td>
</tr>
<tr tal:condition="nothing">
<td class="ContentSelect" valign="top">
<input type="checkbox" name="ids:list" value="id">
</td>
<td class="ContentIcon" valign="top">
<img alt="Service B Icon" src="../../ZMI/www/document_icon.gif" />
</td>
<td class="ContentTitle" valign="top">
<a href="service_b_id">Service B Title or ID here</a>
</td>
<td class="ContentInterface">
Interface A<br/>
Interface B<br/>
</td>
</tr>
</tbody>
</table>
<br />
<input type="submit" name="removeObjects:method" value="Delete"
i18n:attributes="value string:menu_delete_button">
</form>
</div>
</body>
</html>
=== Added File Zope3/lib/python/Zope/App/OFS/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="main" >
<table>
<tr tal:repeat="service container/getServicesTable">
<td tal:content="service/name">Name</td>
<td>
<select name="boundService">
<option tal:repeat="available service/services"
tal:attributes="value available; selected python:service['bound'] == available | nothing"
tal:content="available">Service</option>
</select>
</tr>
</table>
</body>
</html>