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 zope.keyreference.interfaces.IKeyReference support.

The IIntIdsSubclass and event interfaces are new.

interface zc.intid.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.IIntIds[source]

Extends: zc.intid.IIntIdsSet, zc.intid.IIntIdsQuery, zc.intid.IIntIdsManage

A utility that assigns unique ids to objects.

Allows to query object by id and id by object.

interface zc.intid.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 refs structure.

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.

ob is 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.

interface zc.intid.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.IIdRemovedEvent[source]

Extends: zc.intid.IIdEvent

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.

interface zc.intid.IIdAddedEvent[source]

Extends: zc.intid.IIdEvent

A unique id has been added.

The event gets sent when an object is registered in a unique id utility.

interface zc.intid.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.IAfterIdAddedEvent[source]

Extends: zc.intid.ISubscriberEvent

Fired 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.

idmap

The dictionary that holds an (utility -> id) mapping of created ids

interface zc.intid.IBeforeIdRemovedEvent[source]

Extends: zc.intid.ISubscriberEvent

Fired 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.

class zc.intid.BeforeIdRemovedEvent(o, 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.

class zc.intid.AfterIdAddedEvent(o, event, idmap=None)[source]

Bases: object

The event which gets sent when an object is registered in a unique id utility.

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 zc.intid.utility.IntIds(attribute, family=None)[source]

Bases: persistent.Persistent

This utility provides a two way mapping between objects and integer ids.

The objects are stored directly in the internal structures.

generateId(ob)[source]

Generate an id which is not yet taken.

This tries to allocate sequential ids so they fall into the same BTree bucket, and randomizes if it stumbles upon a used one.