Monkey patch to add a missing interface

105 views Asked by At

How can be collective.monkeypatcher used to add a IFooBar in a someproduct?

This is what I tried and it's wrong (because IFooBar doesn't exist in original product.)

<monkey:patch description="Create missing FooBar interface"
              class="someproduct.interfaces.IFooBar"
              original="IFooBar"
              replacement="myproduct.patches.IFooBar"
              docstringWarning="true" />

The error is ConfigurationError: ('Invalid value for', 'class', 'ImportError: Module someproduct.interfaces has no global IFooBar').

My final goal is to skip this error: PicklingError: Can't pickle <class 'someproduct.interfaces.IFooBar'>: attribute lookup someproduct.interfaces.IFooBar failed received when I try to activate / deactivate add-ons.

It is because I have installed a new version of someproduct that has IFooBar, then I reverted to an older version (that has not IFooBar) without uninstalling the add-on.

Update:

Replacing the line:

class="someproduct.interfaces.IFooBar"

with

class="someproduct.interfaces"

it's the same thing. Error: ConfigurationError: Original IFooBar in <module 'someproduct.interfaces' from '/plone/buildout-cache/eggs/someproduct-1.2-py2.7.egg/some/path/interfaces.pyc'> not found.

1

There are 1 answers

0
GhitaB On BEST ANSWER

Oh. Just add: ignoreOriginal="true"