[Checkins] SVN: Sandbox/J1m/zc.persistentkeyreference/s checkpoint
Jim Fulton
jim at zope.com
Fri Nov 18 17:30:24 UTC 2011
Log message for revision 123424:
checkpoint
Changed:
U Sandbox/J1m/zc.persistentkeyreference/setup.py
U Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/configure.zcml
D Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/interfaces.py
U Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.py
U Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.txt
D Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/testing.py
U Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/tests.py
-=-
Modified: Sandbox/J1m/zc.persistentkeyreference/setup.py
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/setup.py 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/setup.py 2011-11-18 17:30:24 UTC (rev 123424)
@@ -24,11 +24,11 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-setup(name = 'zope.keyreference',
- version = '3.6.3dev',
+setup(name = 'zc.persistentkeyreference',
+ version = '0.1dev',
author='Zope Foundation and Contributors',
author_email='zope-dev at zope.org',
- description='Key References',
+ description='Persistent Key References',
long_description=(
read('README.txt')
+ '\n\n' +
@@ -62,6 +62,7 @@
'zope.i18nmessageid',
'zope.interface',
'zope.schema',
+ 'zope.keyreference'
],
include_package_data = True,
zip_safe = False,
Modified: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/configure.zcml
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/configure.zcml 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/configure.zcml 2011-11-18 17:30:24 UTC (rev 123424)
@@ -10,23 +10,18 @@
<require permission="zope.Public" interface=".interfaces.IKeyReference" />
</class>
- <adapter
- for="persistent.interfaces.IPersistent"
- factory=".persistent.connectionOfPersistent"
- />
+ <!-- <\!-- Registering documentation with API doc -\-> -->
+ <!-- <configure -->
+ <!-- xmlns:apidoc="http://namespaces.zope.org/apidoc" -->
+ <!-- xmlns:zcml="http://namespaces.zope.org/zcml" -->
+ <!-- zcml:condition="have apidoc"> -->
- <!-- Registering documentation with API doc -->
- <configure
- xmlns:apidoc="http://namespaces.zope.org/apidoc"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- zcml:condition="have apidoc">
+ <!-- <apidoc:bookchapter -->
+ <!-- id="keyref" -->
+ <!-- title="Persistent Key References" -->
+ <!-- doc_path="persistent.txt" -->
+ <!-- /> -->
- <apidoc:bookchapter
- id="keyref"
- title="Persistent Key References"
- doc_path="persistent.txt"
- />
+ <!-- </configure> -->
- </configure>
-
</configure>
Deleted: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/interfaces.py
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/interfaces.py 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/interfaces.py 2011-11-18 17:30:24 UTC (rev 123424)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Key-reference interfaces
-"""
-import zope.interface
-from zope.schema import DottedName
-from zope.i18nmessageid import MessageFactory
-
-_ = MessageFactory('zope')
-
-
-class NotYet(Exception):
- """Can't compute a key reference for an object
-
- It might be possible to compute one later
- (e.g. at the end of the transaction).
- """
-
-class IKeyReference(zope.interface.Interface):
- """A reference to an object (similar to a weak reference).
-
- The references are compared by their hashes.
- """
-
- key_type_id = DottedName(title=_('Key Type Id'),
- description=_('Key references should sort first '
- 'on their key type and second on any type-specific '
- 'information.')
- )
-
- def __call__():
- """Get the object this reference is linking to.
- """
-
- def __hash__():
- """Get a unique identifier of the referenced object.
- """
-
- def __cmp__(ref):
- """Compare the reference to another reference.
- """
Modified: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.py
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.py 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.py 2011-11-18 17:30:24 UTC (rev 123424)
@@ -20,43 +20,13 @@
import zope.interface
import zope.keyreference.interfaces
+import zope.keyreference.persistent
-class KeyReferenceToPersistent(object):
- """An IKeyReference for persistent objects which is comparable.
+class KeyReferenceToPersistent(
+ zope.keyreference.persistent.KeyReferenceToPersistent):
- These references compare by database name and _p_oids of the objects they
- reference.
- """
- zope.interface.implements(zope.keyreference.interfaces.IKeyReference)
+ key_type_id = 'zc.persistentkeyreference'
- key_type_id = 'zope.app.keyreference.persistent'
-
- def __init__(self, object):
- if not getattr(object, '_p_oid', None):
- connection = IConnection(object, None)
- if connection is None:
- raise zope.keyreference.interfaces.NotYet(object)
-
- connection.add(object)
-
- self.object = object
-
- def __call__(self):
- return self.object
-
- def __hash__(self):
- if isinstance(self.object, PersistentReference):
- # we are doing conflict resolution.
- database_name = self.object.database_name
- if database_name is None:
- # we can't hash
- raise ValueError('database name unavailable at this time')
- oid = self.object.oid
- else:
- database_name = self.object._p_jar.db().database_name
- oid = self.object._p_oid
- return hash((database_name, oid))
-
def __cmp__(self, other):
if self.key_type_id == other.key_type_id:
# While it makes subclassing this class inconvenient,
@@ -94,34 +64,3 @@
return cmp((self_name, self_oid), (other_name, other_oid))
return cmp(self.key_type_id, other.key_type_id)
-
-
- at zope.interface.implementer(IConnection)
-def connectionOfPersistent(ob):
- """An adapter which gets a ZODB connection of a persistent object.
-
- We are assuming the object has a parent if it has been created in
- this transaction.
-
- Raises ValueError if it is impossible to get a connection.
- """
- cur = ob
- while not getattr(cur, '_p_jar', None):
- cur = getattr(cur, '__parent__', None)
- if cur is None:
- return None
- return cur._p_jar
-
-# BBB: If zope.app.keyreference is not installed, we still want
-# old key references to be available. So fake a module to make
-# them unpickleable.
-try:
- import zope.app.keyreference
-except ImportError:
- import sys
- from types import ModuleType as module
- z_a_k = module('zope.app.keyreference')
- sys.modules['zope.app.keyreference'] = z_a_k
- z_a_k_p = module('zope.app.keyreference.persistent')
- z_a_k_p.KeyReferenceToPersistent = KeyReferenceToPersistent
- sys.modules['zope.app.keyreference.persistent'] = z_a_k_p
Modified: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.txt
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.txt 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/persistent.txt 2011-11-18 17:30:24 UTC (rev 123424)
@@ -1,8 +1,8 @@
-=====================================
-Key References for Persistent Objects
-=====================================
+==================================================
+New Improved Key References for Persistent Objects
+==================================================
-`zope.keyreference.persistent.KeyReferenceToPersistent` provides an
+`zc.persistentkeyreference.KeyReferenceToPersistent` provides an
`zope.keyreference.interfaces.IKeyReference` reference for persistent
objects.
Deleted: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/testing.py
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/testing.py 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/testing.py 2011-11-18 17:30:24 UTC (rev 123424)
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Testing components
-"""
-import zope.interface
-import zope.component
-import zope.keyreference.interfaces
-
-class SimpleKeyReference(object):
- """An IReference for all objects. This implementation is *not* ZODB safe.
- """
- zope.component.adapts(zope.interface.Interface)
- zope.interface.implements(zope.keyreference.interfaces.IKeyReference)
-
- key_type_id = 'zope.app.keyreference.simple'
-
- 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)
Modified: Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/tests.py
===================================================================
--- Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/tests.py 2011-11-18 17:21:17 UTC (rev 123423)
+++ Sandbox/J1m/zc.persistentkeyreference/src/zope/keyreference/tests.py 2011-11-18 17:30:24 UTC (rev 123424)
@@ -38,7 +38,7 @@
>>> transaction.commit()
- >>> from zope.keyreference.persistent import KeyReferenceToPersistent
+ >>> from zc.persistentkeyreference import KeyReferenceToPersistent
>>> key1 = KeyReferenceToPersistent(conn1.root()['ob'])
>>> key2 = KeyReferenceToPersistent(conn2.root()['ob'])
More information about the checkins
mailing list