[Zope-dev] oh boy [id,getId() madness]

Stefan H. Holek stefan@epy.co.at
Wed, 11 Jun 2003 21:47:59 +0200


This is definitely possible. You probably have a faulty factory method. In 
Zope, construction is a two step process that looks something like

  def addSomething(self, id, title=''):
      ob = Something(id, title)
      self._setObject(id, ob)

An ObjectManager must know the ids of its subobjects and stores them in the 
_objects attribute.

Hm, _setObject() returns the id the object was actually added to the OM 
with. I think it is allowed to return a different id from the one which got 
passed in (but it never does that as far as I can tell).

Hope this helps,
Stefan


--On Mittwoch, 11. Juni 2003 20:13 +0200 Romain Slootmaekers 
<romain@zzict.com> wrote:

> Yo,
> I have an error in this code fragment:
>
> -------------  fragment ----------
> for childObject in container.objectValues():
>      id=childObject.getId()
>      childObject2=container[id] # sometimes gives a KeyError ????
>      #...
> ------------- /fragment ----------
>
> So it means that there are contained objects with an getId member that
> returns something different than the key that is used for these objects
> in the container object.
>
> As it turns out, I indeed have such objects in my ZODB, and they cause
> all kinds of problems (fe, you can't rename them with the management
> interface)
>
> The questions are:
>    - has anyone else experienced this ?
>    - what could be causing this ?
>


--
The time has come to start talking about whether the emperor is as well
dressed as we are supposed to think he is.               /Pete McBreen/