[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/Browser - ChangeConfigurations.pt:1.1.2.1 ChangeConfigurations.py:1.1.2.1 ConfigurationStatusWidget.py:1.1.2.1 __init__.py:1.1.2.1 configure.zcml:1.1.2.1
Jim Fulton
jim@zope.com
Sat, 30 Nov 2002 07:44:27 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/Browser
In directory cvs.zope.org:/tmp/cvs-serv30047/lib/python/Zope/App/OFS/Services/Browser
Added Files:
Tag: Zope3-Bangalore-TTW-Branch
ChangeConfigurations.pt ChangeConfigurations.py
ConfigurationStatusWidget.py __init__.py configure.zcml
Log Message:
Refactored the way TTW component registration is done. There are now
separate registry objects that abstract the machinery for registering
multiple conflicting configurations and deciding which, if any are
active. Also provided a new field and widget for the status
information.
Along the way, cleaned up and streamlined placeful testing
infrastructure a bit.
Now checking into branch. Will give file-by-file (or at least more
specific logs) when the changes are merged into the head.
=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ChangeConfigurations.pt ===
<table width="100%">
<tr tal:define="message view/message" tal:condition="message">
<td></td>
<td colspan="2"><em tal:content="message">xxxx</em></td>
</tr>
<tr tal:repeat="configuration view/configurations">
<td><input type="radio" name="Roles" value="0"
tal:attributes="
name view/name;
value configuration/id;
checked configuration/active;
"
/>
</td>
<td><a href="."
tal:attributes="href string:${view/configBase}/${configuration/id}"
tal:content="configuration/id"
>foo/bar</a></td>
<td tal:content="structure configuration/summary">
Configuration summary
</td>
</tr>
<tr>
<td><input type="radio" name="Roles" value="disable"
tal:attributes="
name view/name;
checked view/inactive;
"
/></td>
<td><em>Disable</em></td>
</tr>
</table>
=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ChangeConfigurations.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: ChangeConfigurations.py,v 1.1.2.1 2002/11/30 12:44:26 jim Exp $
"""
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.ComponentArchitecture import getView, getServiceManager
from Zope.Proxy.ProxyIntrospection import removeAllProxies
class ChangeConfigurations(BrowserView):
_prefix = 'configurations'
name = _prefix + ".active"
message = ''
configBase = ''
def setPrefix(self, prefix):
self._prefix = prefix
self.name = prefix + ".active"
def applyUpdates(self):
message = ''
if 'submit_update' in self.request.form:
active = self.request.form.get(self.name)
if active == "disable":
active = self.context.active()
if active is not None:
self.context.deactivate(active)
message = "Disabled"
else:
for info in self.context.info():
if info['id'] == active:
if not info['active']:
self.context.activate(info['configuration'])
message = "Updated"
return message
def update(self):
message = self.applyUpdates()
self.configBase = str(getView(getServiceManager(self.context),
'absolute_url', self.request)
) + '/Packages'
configurations = self.context.info()
# This is OK because configurations is just a list of dicts
configurations = removeAllProxies(configurations)
inactive = 1
for info in configurations:
if info['active']:
inactive = None
else:
info['active'] = None
info['summary'] = getView(info['configuration'],
'ConfigurationSummary',
self.request)
self.inactive = inactive
self.configurations = configurations
self.message = message
=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ConfigurationStatusWidget.py ===
##############################################################################
#
# Copyright (c) 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.
#
##############################################################################
"""Configuration Browser Views
XXX longer description goes here.
$Id: ConfigurationStatusWidget.py,v 1.1.2.1 2002/11/30 12:44:26 jim Exp $
"""
__metaclass__ = type
from Zope.App.Forms.Views.Browser.Widget import BrowserWidget
from Zope.App.OFS.Services.ConfigurationInterfaces \
import Active, Registered, Unregistered
class ConfigurationStatusWidget(BrowserWidget):
def __call__(self):
checked = self._showData() or Unregistered
result = [
('<input type="radio" name="%s" value="%s"%s> %s'
% (self.name, v, (v == checked and ' checked' or ''), v)
)
for v in (Unregistered, Registered, Active)
]
return '<br />'.join(result)
=== Added File Zope3/lib/python/Zope/App/OFS/Services/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/Browser/configure.zcml ===
<zope:zopeConfigure
xmlns:zope='http://namespaces.zope.org/zope'
xmlns="http://namespaces.zope.org/browser"
package="Zope.App.OFS.Services"
>
<view
for=".ConfigurationInterfaces.IConfigurationStatus"
name="widget"
factory=".Browser.ConfigurationStatusWidget."
allowed_interface="Zope.App.Forms.Views.Browser.IBrowserWidget."
permission="Zope.ManageServices"
/>
<view
for=".ConfigurationInterfaces.IConfigurationRegistry"
name="ChangeConfigurations"
template="Browser/ChangeConfigurations.pt"
class=".Browser.ChangeConfigurations."
allowed_interface="Zope.App.Forms.Browser.IFormCollaborationView."
permission="Zope.ManageServices"
/>
</zope:zopeConfigure>