Reference¶
Interfaces¶
Interfaces for the unique id utility.
Note that most of these interfaces present identical method signatures
to those of their zope.intid counterparts. This includes everything
that comprises the IIntIds interface.
Note that the contracts for these APIs differs, primarily in not
requiring IKeyReference support
(however, the provided lifecycle event subscribers in
zc.intid.subscribers do require this support).
The IIntIdsSubclass and event interfaces are new.
-
exception
zc.intid.interfaces.IntIdMismatchError[source]¶ Bases:
zope.intid.interfaces.IntIdMissingErrorRaised from
getIdif the id of an object doesn’t match what’s recorded in the utility.
-
exception
zc.intid.interfaces.IntIdInUseError[source]¶ Bases:
ValueErrorRaised by the utility when
registertries to reuse an intid.
-
interface
zc.intid.interfaces.IIntIdsQuery[source]¶ Finding IDs by object and objects by ID.
-
getObject(uid)¶ Return an object by its unique id
Raises: zope.intid.interfaces.ObjectMissingError – if there is no object with that id.
-
getId(ob)¶ Get a unique id of an object.
Raises: - zope.intid.interfaces.IntIdMissingError – if there is no id for that object.
- zc.intid.interfaces.IntIdMismatchError – if the recorded id doesn’t match the id of the 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
zc.intid.interfaces.IIntIdsSet[source]¶ Establishing and destroying the connection between an object and an ID.
-
register(ob)¶ Register an object and returns a unique id generated for it.
If the object is already registered, its id is returned anyway.
If not already registered, the registration is made and an
IIdAddedEventis generated.
-
unregister(ob)¶ Remove the object from the indexes.
If the ob is not previously registered, this has no effect.
An
IIdRemovedEventis triggered for successful unregistrations.
-
-
interface
zc.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
zc.intid.interfaces.IIntIds[source]¶ Extends:
zc.intid.interfaces.IIntIdsSet,zc.intid.interfaces.IIntIdsQuery,zc.intid.interfaces.IIntIdsManageA utility that assigns unique ids to objects.
Allows to query object by id and id by object.
-
interface
zc.intid.interfaces.IIntIdsSubclass[source]¶ Additional interface that subclasses can usefully use.
-
family¶ BTree family used for this id utility.
This will be either BTree.family32 or BTree.family64.
This may not be modified, but may be used to create additional structures of the same integer family as the
refsstructure.
-
refs¶ BTree mapping from id to object.
Subclasses can use this to determine whether an id has already been assigned.
This should not be directly modified by subclasses.
-
generateId(ob)¶ Return a new iid that isn’t already used.
obis the object the id is being generated for.The default behavior is to generate arbitrary integers without reference to the objects they’re generated for.
This method may be overriden.
If this method returns an id that is already in use,
registerwill raise anIntIdInUseError.
-
-
interface
zc.intid.interfaces.IIdEvent[source]¶ Generic base interface for IntId-related events
-
object¶ The object related to this event
-
idmanager¶ The int id utility generating the event.
-
id¶ The id that is being assigned or unassigned.
-
-
interface
zc.intid.interfaces.IIdRemovedEvent[source]¶ Extends:
zc.intid.interfaces.IIdEventA 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.
-
interface
zc.intid.interfaces.IIdAddedEvent[source]¶ Extends:
zc.intid.interfaces.IIdEventA unique id has been added.
The event gets sent when an object is registered in a unique id utility.
-
interface
zc.intid.interfaces.ISubscriberEvent[source]¶ An event fired by the subscribers in relation to another event.
-
object¶ The object related to this event
-
original_event¶ The ObjectEvent related to this event
-
-
interface
zc.intid.interfaces.IAfterIdAddedEvent[source]¶ Extends:
zc.intid.interfaces.ISubscriberEventFired after all utilities have registered unique ids.
This event is guaranteed to be the last event fired by the subscribers that register ids. It will be fired exactly once, no matter how many utilities registered ids.
This has a similar purpose and structure to
zope.intid.interfaces.IIntIdAddedEvent.-
idmap¶ The dictionary that holds an (utility -> id) mapping of created ids
-
-
interface
zc.intid.interfaces.IBeforeIdRemovedEvent[source]¶ Extends:
zc.intid.interfaces.ISubscriberEventFired before any utility removes an object’s unique ID.
This event is guaranteed to be the first event fired by the subscriber that removes IDs. It will only be fired if at least one utility will remove an ID.
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.