[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - hub.py:1.5 hubcontrol.pt:1.7

Garrett Smith cvs-admin at zope.org
Fri Oct 31 18:11:45 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv26780/src/zope/app/browser/services

Modified Files:
	hub.py hubcontrol.pt 
Log Message:
Added the ability to view registered object (paths, hub ids, and status).
Missing objects (i.e. objects that cannot be traversed to via the
registered path) are highlighted in red.

Missing objects can still be removed via a 'Remove Missing Objects'
button.


=== Zope3/src/zope/app/browser/services/hub.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/services/hub.py:1.4	Thu Aug  7 13:41:03 2003
+++ Zope3/src/zope/app/browser/services/hub.py	Fri Oct 31 18:11:14 2003
@@ -15,10 +15,43 @@
 
 $Id$
 """
+from zope.exceptions import NotFoundError
+
 from zope.app.interfaces.services.hub 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
+


=== Zope3/src/zope/app/browser/services/hubcontrol.pt 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/services/hubcontrol.pt:1.6	Thu Aug  7 20:14:32 2003
+++ Zope3/src/zope/app/browser/services/hubcontrol.pt	Fri Oct 31 18:11:14 2003
@@ -15,12 +15,36 @@
     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>




More information about the Zope3-Checkins mailing list