Author: jmorliaguet Date: Sat May 27 16:33:19 2006 New Revision: 3249 Modified: cpsskins/branches/paris-sprint-2006/configure.zcml cpsskins/branches/paris-sprint-2006/uids.py
Log: - moved zope.app.keyreference.testing.SimpleKeyReference here Modified: cpsskins/branches/paris-sprint-2006/configure.zcml ============================================================================== --- cpsskins/branches/paris-sprint-2006/configure.zcml (original) +++ cpsskins/branches/paris-sprint-2006/configure.zcml Sat May 27 16:33:19 2006 @@ -70,6 +70,13 @@ </class> + <!-- UIDs --> + + <adapter + for="*" + factory=".uids.RAMKeyReference" + /> + <!-- Package includes --> <include package=".perspectives" /> Modified: cpsskins/branches/paris-sprint-2006/uids.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/uids.py (original) +++ cpsskins/branches/paris-sprint-2006/uids.py Sat May 27 16:33:19 2006 @@ -20,9 +20,30 @@ from zope.app.intid import IntIds from zope.app.intid.interfaces import IIntIds from zope.app.keyreference.interfaces import IKeyReference, NotYet -from zope.app.keyreference.testing import SimpleKeyReference +from zope.interface import implements from zope.security.proxy import removeSecurityProxy +class RAMKeyReference(object): + """An IReference for all objects. This implementation is *not* ZODB safe. + """ + implements(IKeyReference) + + key_type_id = 'cpsskins.ram.keyreference' + + def __init__(self, object): + self.object = object + + def __call__(self): + return self.object + + def __hash__(self): + return hash(self.object) + + def __cmp__(self, other): + if self.key_type_id == other.key_type_id: + return cmp(hash(self.object), hash(other)) + return cmp(self.key_type_id, other.key_type_id) + class IUids(IIntIds): pass @@ -34,7 +55,7 @@ except TypeError: raise KeyError(ob) except NotYet: - key = SimpleKeyReference(ob) + key = RAMKeyReference(ob) try: return self.ids[key] @@ -46,7 +67,7 @@ try: key = IKeyReference(ob) except NotYet: - key = SimpleKeyReference(ob) + key = RAMKeyReference(ob) if key in self.ids: return self.ids[key] @@ -60,7 +81,7 @@ try: key = IKeyReference(ob) except NotYet: - key = SimpleKeyReference(ob) + key = RAMKeyReference(ob) if key is None: return -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins