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

Fred Drake fdrake at gmail.com
Fri Nov 20 09:09:04 EST 2009


On Thu, Nov 19, 2009 at 11:20 PM, Roger <dev at projekt01.ch> wrote:
> The zope.intid.removeIntIdSubscriber and addIntIdSubscriber
> are calling IIntIds.register with a IKeyReference adapter
> as argument instead of using the proxied object.

Your comments are entirely related to the zope.intid implementation
and the subscribers provided with that.  None of these comments
pertain to zc.intid.

I'll respond anyway:

It doesn't make sense to see key references as proxies.

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

Arguably, but the result will be the same:

- The key reference will be stored in the zope.intid utility.

- Asking the utility to return the object for the id will return
  the object from which the key reference was created.

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

Since you're worrying about the zope.intid subscribers, I'm going to
presume that you're concerned about the zope.intid implementation, or
you're thinking that it makes sense to use those subscribers with the
zc.intid package.

With the zope.intid implementation, there isn't a problem, as explained above.

Don't use those subscribers with the zc.intid implementation.  That
was never intended.  Since those subscribers are registered for the
zope.intid interfaces, and not the (parallel but unrelated) interfaces
from zc.intid, use of zc.intid utilities will not cause existing uses
of those subscribers to break.

I do not advocate using the subscribers from zope.intid, even with the
zope.intid implementation.  They are promiscuous.

> 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?

Sure.  I just don't care about that, since I don't use those subscribers.

> 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

It looks like you've done some work to avoid the conflicts generated
for the ids mapping as well.  zc.intid complete avoids the key
reference dance entirely, since it's unnecessary once that mapping has
been removed.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
"Chaos is the score upon which reality is written." --Henry Miller


More information about the checkins mailing list