[Checkins] SVN: zc.intid/trunk/ initial implementation

Roger dev at projekt01.ch
Thu Nov 19 23:20:35 EST 2009


Hi Fred 

> Betreff: [Checkins] SVN: zc.intid/trunk/ initial implementation

The zope.intid.removeIntIdSubscriber and addIntIdSubscriber
are calling IIntIds.register with a IKeyReference adapter
as argument instead of using the proxied object.

This is wrong in zope.intid and the subscribers should call
the register method with a object instead of using the
IKeyReference (key).

See the interface:

class IIntIdsSet(Interface):

    def 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.
        """


This means your IntIds utility will store the real object
if someone will call the register method with an object instead
of useing a IKeyReference like described in the IIntIds interface.

Or it will apply the uid to the IKeyReference adapter
if the zope.intid subscribers get used.

Can you agree that the subscriber should not call
the register method within a IKeyReference key?

In custom IIntIds utility I do something like that:

def register(self, obj):
    if IKeyReference.providedBy(obj):
        obj = obj()
    obj = removeSecurityProxy(obj)
    if obj.oid is None:
        key = IKeyReference(obj)
        uid = self._generateId(obj)
        self.refs[uid] = key
        obj.oid = uid
       # notify added event
    return obj.oid

Regards
Roger Ineichen



More information about the checkins mailing list