Re: Zope 2 and broken interfaces

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sylvain Viollon wrote:
> Hello,
> 
>    I like to refactor my code and often make broken interfaces:
> 
>    On a ZODB object I do an alsoProvide of an interface.
> 
>    Now I remove the corresponding code for that interface (and that
>    object but it is not required) and I restart my server. I didn't
>    moved them, I just removed them. (If I moved them I would use
>    zodbupdate, and have no problem).
> 
>    But let say I need to remove that object from ZODB. Unpickling that
>    object fail in the custom set_state of zope.interface with the well known
>    error:
> 
>    File ".../zope.interface-3.5.3-py2.6-linux-i686.egg/zope/interface/adapter.py",
>    line 470, in add_extendor for i in provided.__iro__:
> 
>    AttributeError: type object 'IKeyManager' has no attribute '__iro__'
> 
>    Because it expect to get an interface to restore the alsoProvides,
>    and got a broken interface instead (which is just like a regular
>    broken object).
> 
>    And you cannot access your ZODB anymore, since this broken object, with
>    its broken interface is unpickled when its container is.
> 
>    I found a way 'to prevent' this error, by adding an attribute
>    __iro__ which is an empty tuple to OFS.Uninstalled.BrokenClass.
>    That let me load this broken object, and delete it (along with the reference
>    to the broken interface).
> 
>    I think it is the good behavior, and since you cannot modify a broken
>    object, if you put back the code after, your object will work again,
>    with its interface provided as well.
> 
>    If we can fix this problem in Zope 2, (with this solution, or an another),
>    I would be the most happy user of all :).

Your strategy seems pretty reasonable to me.  Please file a bug with
your patch.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkybQ/0ACgkQ+gerLs4ltQ5XyQCcDob+Nxf5gpfXqBo8vYp5KSFT
yU0An3IAG6FUg4S5F1fbtN2JcmV4tkuk
=A6mD
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.