[Zope3-Users] Re: Why in apidoc,
I don't found the interface must be implemented to be register by
IntIds ?
KLEIN Stéphane
klein.stephane at gmail.com
Sat Sep 30 05:22:59 EDT 2006
2006/9/30, Philipp von Weitershausen <philipp at weitershausen.de>:
> KLEIN Stéphane wrote:
> > I read IntIds apidoc, I see :
> >
> > # register(ob)
> > Interface : zope.app.intid.interfaces.IIntIdsSet
> > Permissions : zope.ManageContent (lecture), non disponible (écriture)
>
> When quoting things from the Zope ZMI, I suggest switching to English
> first. Not everyone understands French.
Sorry :(
...
> By the way, it probably doesn't work because you're missing an adapter
> for 'obj' to IKeyReference. This is necessary to make it work and
> required by intid utilities as documented in one of the zope.app.intid
> interfaces:
>
> 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.
> """
>
> So, you first need to register an IKeyReference adapter for your 'P()'
> object.
Now, I do that :
>>> class P(Persistent):
... pass
...
>>> from zope.app.keyreference.persistent import KeyReferenceToPersistent
>>> from zope.app.keyreference.interfaces import IKeyReference
>>> from zope.app.testing import setup, ztapi
>>> from persistent.interfaces import IPersistent
>>> ztapi.provideAdapter(IPersistent, IKeyReference, KeyReferenceToPersistent)
>>> from zope.app.intid import IntIds
>>> u = IntIds()
>>> obj = object()
>>> obj = P()
>>> uid = u.register(obj)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/app/intid/__init__.py",
line 110, in register
key = IKeyReference(ob)
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/interface/interface.py",
line 675, in __call__
adapter = self.__adapt__(obj)
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/interface/interface.py",
line 742, in __adapt__
adapter = hook(self, obj)
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/app/component/hooks.py",
line 96, in adapter_hook
return siteinfo.adapter_hook(interface, object, name, default)
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/interface/adapter.py",
line 415, in adapter_hook
adapter = factory(object)
File "/home/harobed/zope/Zope-3.2.1/build/lib.linux-i686-2.4/zope/app/keyreference/persistent.py",
line 41, in __init__
raise zope.app.keyreference.interfaces.NotYet(object)
zope.app.keyreference.interfaces.NotYet: <__main__.P object at 0xb6969dec>
What is it ? I've IPersistent adapter to IKeyReference. I don't
understand what is "zope.app.keyreference.interfaces.NotYet:
<__main__.P object at 0xb6969dec>" ?
> > Where can I found documentation about IntIds ?
>
> My new book :)
Yes! I want it !
Thanks for your help,
Stephane
More information about the Zope3-users
mailing list