On Sun, Apr 08, 2012 at 01:04:37PM -0700, Ross Patterson wrote:
> experimental.broken is working well for me. It greatly aided me in
> getting through a particularly nasty upgrade allowing me to cleanup the
> ZCA cruft left by poorly behaved add-ons. I'd like to proceed with
> adding the core of this to zope.interface and I need the
> developers/maintainers to weigh in.
>
> The first and most fundamental matter is changing interface pickles such
> that they can be unpickled into something that can fulfill the minimum
> interface contract and don't break the ZCA. To that end, I'd like to
> add the following to zope.interface.interface:
>
> ...
> try:
> from ZODB.broken import find_global
> from ZODB.broken import IBroken
> def find_interface(modulename, globalname,
> Broken=IBroken, type=InterfaceClass):
> """
> Find a global interface, returning a broken interface if it can't be found.
> """
> return find_global(modulename, globalname,
> Broken=IBroken, type=InterfaceClass)
> except ImportError:
> IBroken = Interface
> def find_interface(modulename, globalname,
> Broken=IBroken, type=InterfaceClass):
> """
> Find a global interface, raising ImportError if it can't be found.
> """
> # From pickle.Unpickler.find_class
> __import__(module)
> mod = sys.modules[module]
> klass = getattr(mod, name)
> return klass
> ...
> class InterfaceClass(Element, InterfaceBase, Specification):
> ...
> def __reduce__(self):
> if self is IBroken:
> return self.__name__
> return (find_interface, (modulename, globalname))
> ...
-1