[Zope3-checkins] CVS: Zope3/src/zope/app/event - subs.py:1.4

Steve Alexander steve@cat-box.net
Mon, 3 Feb 2003 10:59:43 -0500


Update of /cvs-repository/Zope3/src/zope/app/event
In directory cvs.zope.org:/tmp/cvs-serv23130/src/zope/app/event

Modified Files:
	subs.py 
Log Message:
Large event service reimplementation.


=== Zope3/src/zope/app/event/subs.py 1.3 => 1.4 === (675/775 lines abridged)
--- Zope3/src/zope/app/event/subs.py:1.3	Tue Jan 28 07:11:29 2003
+++ Zope3/src/zope/app/event/subs.py	Mon Feb  3 10:59:10 2003
@@ -2,14 +2,14 @@
 #
 # 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.
-# 
+#
 ##############################################################################
 """
 Revision information:
@@ -18,6 +18,9 @@
 from __future__ import generators
 from zope.exceptions import NotFoundError
 from persistence import Persistent
+from zodb.btrees.OOBTree import OOBTree
+from zodb.btrees.IOBTree import IOBTree
+
 from types import StringTypes
 
 from zope.proxy.context import ContextMethod
@@ -29,7 +32,9 @@
 from zope.app.interfaces.event import ISubscribingAware
 
 from zope.component import getService, getAdapter, queryAdapter
-from zope.interface.type import TypeRegistry
+from zope.app.services.type import PersistentTypeRegistry
+from cPickle import dumps, PicklingError
+import logging
 
 __metaclass__ = type
 
@@ -38,11 +43,10 @@
 except NameError:
     def enumerate(collection):
         'Generates an indexed series:  (0,coll[0]), (1,coll[1]) ...'
-        i = 0
-        it = iter(collection)
-        while 1:
-            yield (i, it.next())
-            i += 1
+        count = 0

[-=- -=- -=- 675 lines omitted -=- -=- -=-]

+    path = None
+
+    clean_reference = removeAllProxies(reference)
+
+    if isinstance(clean_reference, int):
+        reftype = int
+        hubId = clean_reference
+        hub = getService(context, "HubIds")
+        try:
+            wrappedobj = hub.getObject(hubId)
+        except NotFoundError:
+            wrappedobj = None
+        else:
+            if allways:
+                try:
+                    # Hub can't resolve the object, but it might still know
+                    # the location the object is supposed to be at.
+                    path = hub.getLocation(hubId)
+                    # XXX remove this next line when objecthub is refactored
+                    path = locationAsUnicode(path)
+                except NotFoundError:
+                    path = getPhysicalPathString(wrappedobj)
+            cleanobj = removeAllProxies(wrappedobj)
+    elif isinstance(clean_reference, StringTypes):
+        reftype = unicode
+        path = locationAsUnicode(clean_reference)
+        try:
+            wrappedobj = traverse(context, path)
+        except NotFoundError:
+            wrappedobj = None
+        else:
+            cleanobj = removeAllProxies(wrappedobj)
+            if allways:
+                hub = getService(context, 'HubIds')
+                try:
+                    hubId = hub.getHubId(path)
+                except NotFoundError:
+                    pass
+    else:
+        reftype = object
+        wrappedobj = reference
+        cleanobj = clean_reference
+        path = getPhysicalPathString(wrappedobj)
+        hub = getService(context, "HubIds")
+        try:
+            hubId = hub.getHubId(path)
+        except NotFoundError:
+            pass
+
+    return cleanobj, wrappedobj, path, hubId, reftype