[Zope3-checkins] CVS: Zope3/src/zope/app/hub/browser -
__init__.py:1.1 configure.zcml:1.1 hub.gif:1.1
hubcontrol.pt:1.1 subscription_control.pt:1.1
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Mar 11 04:19:26 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/hub/browser
In directory cvs.zope.org:/tmp/cvs-serv28114/src/zope/app/hub/browser
Added Files:
__init__.py configure.zcml hub.gif hubcontrol.pt
subscription_control.pt
Log Message:
Moved object hub to zope.app.hub. I did provide module aliases.
=== Added File Zope3/src/zope/app/hub/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.
#
##############################################################################
"""Define view component for object hub.
$Id: __init__.py,v 1.1 2004/03/11 09:19:25 srichter Exp $
"""
from zope.exceptions import NotFoundError
from zope.app.hub.interfaces import IObjectHub
from zope.app.i18n import ZopeMessageIDFactory as _
class Control:
__used_for__ = IObjectHub
# XXX: Another dead chicken. Guys, this view could do soo much, like aehm,
# display the cataloged objects with a nice filter function?
def objects(self):
"""Returns a sequence of objects registered with the hub.
Each item in the sequence is a map:
path - path to the object as stored in the hub
id - object id as stored in the hub
status - either 'Missing' or 'OK'
ok - True if statis 'OK', False otherwise
Missing objects are those that cannot be accessed via the hub
with a call to getObject (NotFoundError raised).
"""
result = []
hub = self.context
for path, id in hub.iterRegistrations():
try:
hub.getObject(id)
status = _("OK")
ok = True
except NotFoundError:
status = _("Missing")
ok = False
result.append({'path':path, 'id':id, 'status':status, 'ok':ok})
result.sort(lambda lhs, rhs: cmp(lhs['path'], rhs['path']))
return result
=== Added File Zope3/src/zope/app/hub/browser/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
<page
name="index.html"
menu="zmi_views" title="Control"
permission="zope.ManageServices"
for="zope.app.hub.interfaces.IObjectHub"
class=".Control"
template="hubcontrol.pt" />
<addMenuItem
class="zope.app.hub.ObjectHub"
permission="zope.ManageServices"
title="HubIds Service"
description="An object hub, for cataloging, unique object ids, and
more: use sparingly" />
<icon
name="zmi_icon"
for="zope.app.hub.interfaces.IObjectHub"
file="hub.gif" />
<!-- Registration -->
<menuItem
menu="add_component"
for="zope.app.container.interfaces.IAdding"
action="zope.app.hub.Registration"
title="Registration subscriber"
description="An event subscriber that registers content with the objecthub"
permission="zope.ManageServices" />
/>
<page
for="zope.app.hub.interfaces.ISubscriptionControl"
permission="zope.ManageServices"
name="index.html"
menu="zmi_views"
title="Control"
template="subscription_control.pt" />
</zope:configure>
=== Added File Zope3/src/zope/app/hub/browser/hub.gif ===
<Binary-ish file>
=== Added File Zope3/src/zope/app/hub/browser/hubcontrol.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<div class="message" tal:condition="request/unregister_missing|nothing"
i18n:translate="">
<span tal:replace="context/unregisterMissingObjects"
i18n:name="missing_num">5</span> object(s) unregistered.
</div>
<p i18n:translate="">
This is an object hub. There are
<span tal:replace="context/numRegistrations"
i18n:name="num_objects">42</span>
objects registered.
</p>
<div tal:condition="not:request/view_registrations|nothing">
<p>
<a i18n:translate=""
href="?view_registrations=1">View Object Registrations</a>
</p>
</div>
<div tal:condition="request/view_registrations|nothing">
<p>
<a i18n:translate=""
href=".">Hide Object Registrations</a>
</p>
<table>
<tr>
<th>Path</th>
<th>Object ID</th>
<th>Status</th>
</tr>
<tr tal:repeat="object view/objects"
tal:attributes="style python:not object['ok'] and 'color:red' or nothing">
<td tal:content="object/path">/foo/bar</td>
<td tal:content="object/id">87387239</td>
<td tal:content="object/status">OK</td>
</tr>
</table>
</div>
<form>
<input type="submit" name="unregister_missing"
value="Unregister Missing Objects"
i18n:attributes="value"/>
</form>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/hub/browser/subscription_control.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" i18n:translate="">
Registration "Service" Control Page
</title>
</head>
<body>
<div metal:fill-slot="body">
<h1 i18n:translate="">Subscription control</h1>
<!-- XXX: Too much logic for a simple template! -->
<span tal:condition="request/callSubscribe|nothing" tal:omit-tag="">
<span tal:define="dummy context/subscribe" tal:omit-tag=""/>
<span i18n:translate="">Successfully subscribed.</span>
</span>
<span tal:condition="request/callUnsubscribe|nothing" tal:omit-tag="">
<span tal:define="dummy context/unsubscribe" tal:omit-tag=""/>
<span i18n:translate="">Successfully unsubscribed.</span>
</span>
<span tal:condition="request/callRegisterExisting|nothing" tal:omit-tag="">
<span tal:define="dummy context/registerExisting" tal:omit-tag=""/>
<span i18n:translate="">Registration done.</span>
</span>
<form action="" method="post">
<span tal:condition="context/isSubscribed" tal:omit-tag="">
<span i18n:translate="">Subscription state: ON</span>
<input type="submit" value="Unsubscribe" name="callUnsubscribe" />
</span>
<span tal:condition="not:context/isSubscribed" tal:omit-tag="">
<span i18n:translate="">Subscription state: OFF</span>
<input type="submit" value="Subscribe" name="callSubscribe" />
</span>
</form>
<form action="" method="post">
<input type="submit" value="Register Existing Objects"
name="callRegisterExisting" i18n:attributes="value"/>
</form>
</div>
</body>
</html>
More information about the Zope3-Checkins
mailing list