What is zope.intid?¶
This package provides an API to create integer ids for any object. Later objects can be looked up by their id as well. This functionality is commonly used in situations where dealing with objects is undesirable, such as in search indices or any code that needs an easy hash of an object.
Reference¶
Interfaces¶
Interfaces for the unique id utility.
-
exception
zope.intid.interfaces.
IntIdMissingError
[source]¶ Bases:
exceptions.KeyError
Raised when
getId
cannot find an intid.
-
exception
zope.intid.interfaces.
ObjectMissingError
[source]¶ Bases:
exceptions.KeyError
Raised when
getObject
cannot find an object.
-
exception
zope.intid.interfaces.
IntIdsCorruptedError
[source]¶ Bases:
exceptions.KeyError
Raised when internal corruption is detected in the utility.
Users should not need to catch this because this situation should not happen.
-
interface
zope.intid.interfaces.
IIntIdsQuery
[source]¶ Query for IDs and objects
-
getObject
(uid)¶ Return an object by its unique id
-
getId
(ob)¶ Get a unique id of an object.
-
queryObject
(uid, default=None)¶ Return an object by its unique id
Return the default if the uid isn’t registered
-
queryId
(ob, default=None)¶ Get a unique id of an object.
Return the default if the object isn’t registered
-
__iter__
()¶ Return an iteration on the ids
-
-
interface
zope.intid.interfaces.
IIntIdsSet
[source]¶ Register and unregister objects.
-
register
(ob)¶ Register an object and returns a unique id generated for it.
The object must be adaptable to
IKeyReference
.If the object is already registered, its id is returned anyway.
-
unregister
(ob)¶ Remove the object from the indexes.
IntIdMissingError is raised if ob is not registered previously.
-
-
interface
zope.intid.interfaces.
IIntIdsManage
[source]¶ Some methods used by the view.
-
__len__
()¶ Return the number of objects indexed.
-
items
()¶ Return a list of (id, object) pairs.
-
-
interface
zope.intid.interfaces.
IIntIds
[source]¶ Extends:
zope.intid.interfaces.IIntIdsSet
,zope.intid.interfaces.IIntIdsQuery
,zope.intid.interfaces.IIntIdsManage
A utility that assigns unique ids to objects.
Allows to query object by id and id by object.
-
interface
zope.intid.interfaces.
IIntIdEvent
[source]¶ Generic base interface for IntId-related events
-
object
¶ The object related to this event
-
original_event
¶ The ObjectEvent related to this event
-
-
interface
zope.intid.interfaces.
IIntIdRemovedEvent
[source]¶ Extends:
zope.intid.interfaces.IIntIdEvent
A unique id will be removed
The event is published before the unique id is removed from the utility so that the indexing objects can unindex the object.
-
class
zope.intid.interfaces.
IntIdRemovedEvent
(object, event)[source]¶ Bases:
object
The event which is published before the unique id is removed from the utility so that the catalogs can unindex the object.
-
interface
zope.intid.interfaces.
IIntIdAddedEvent
[source]¶ Extends:
zope.intid.interfaces.IIntIdEvent
A unique id has been added
The event gets sent when an object is registered in a unique id utility.
-
idmap
¶ The dictionary that holds an (utility -> id) mapping of created ids
-
Implementation¶
Unique id utility.
This utility assigns unique integer ids to objects and allows lookups by object and by id.
This functionality can be used in cataloging.
-
class
zope.intid.
IntIds
(family=None)[source]¶ Bases:
persistent.Persistent
This utility provides a two way mapping between objects and integer ids.
IKeyReferences to objects are stored in the indexes.
-
zope.intid.
removeIntIdSubscriber
(ob, event)[source]¶ A subscriber to ObjectRemovedEvent
Removes the unique ids registered for the object in all the unique id utilities.
Changes¶
4.4.0 (2021-03-19)¶
- Fixed deprecation warning for
zope.site.hooks
in tests. - Add support for Python 3.7 and 3.8.
- Drop support for Python 3.4.
- Fix incorrect import of
zope.interface.interfaces.IComponentLookup
in tests.
4.3.0 (2017-07-26)¶
- Add support for Python 3.6.
- Drop support for Python 3.3.
4.2.0 (2016-12-08)¶
- Raise more informative KeyError subclasses from the utility when intids or objects cannot be found. This distinguishes them from errors raised by normal dictionaries or BTrees, and is useful in unit testing or when persisting intids or sharing them among processes for later or concurrent use.
- Propagate
POSKeyError
fromqueryId
instead of returning the default object. This exception indicates a corrupt database, not a missing object. ThequeryObject
function already behaved this way. - Stop depending on ZODB for anything except testing.
- Add support for Python 3.5 and PyPy3 5.2.
- Drop support for Python 2.6.
4.1.0 (2014-12-27)¶
- Add support for PyPy (PyPy3 blocked on PyPy3-compatible
zodbpickle
). - Add support for Python 3.4.
4.0.0 (2014-12-20)¶
- Add support for testing on Travis.
4.0.0a1 (2013-02-22)¶
- Add support for Python 3.3.
- Replace deprecated
zope.interface.implements
usage with equivalentzope.interface.implementer
decorator. - Drop support for Python 2.4 and 2.5.
- Bug fix: ensure that the IntId utility never generates ids greater than the maxint of the BTree family being used.
3.7.2 (2009-12-27)¶
- Use the zope.component API in favor of ztapi.
- Remove
zope.app.testing
dependency.
3.7.1 (2009-05-18)¶
- Remove dependencies on
zope.container
. Instead importObject*Event
classes fromzope.lifecycleevent
and importIContained
fromzope.location
. In order to be able to do this, depend onzope.lifecycleevent
>=3.5.2 andzope.location
>=3.5.4. - Remove a dependency on
zope.container.contained.Contained
(this is a dumb base class that defines __parent__ and __name__ as None and declares that the class implements IContained).
3.7.0 (2009-02-01)¶
- Split out this package from
zope.app.intid
. The latter one now only contains browser views and compatibility imports while whole IntId functionality is moved here.
Project URLs¶
- http://pypi.python.org/pypi/zope.intid (PyPI entry and downloads)