Skip to content

Instantly share code, notes, and snippets.

@mgedmin
Created September 11, 2014 14:41
Show Gist options
  • Select an option

  • Save mgedmin/a8d9006166e301cee534 to your computer and use it in GitHub Desktop.

Select an option

Save mgedmin/a8d9006166e301cee534 to your computer and use it in GitHub Desktop.
Zope 2 is wonderful
# This is what I need to do if I want to import a .zexp from Zope 2.12 because there's apparently some object in the ZODB that got removed in 2.11 days
import mock
sys.modules['Products.PluginIndexes.TextIndex'] = mock.Mock()
sys.modules['Products.PluginIndexes.TextIndex.Splitter'] = mock.Mock()
sys.modules['Products.PluginIndexes.TextIndex.Splitter.ZopeSplitter'] = mock.Mock()
from persistent import Persistent
sys.modules['Products.PluginIndexes.TextIndex.Splitter.ZopeSplitter'].ZopeSplitter = type('ZopeSplitter', (Persistent,), {'__module__': 'Products.PluginIndexes.TextIndex.Splitter.ZopeSplitter'})
@wealthmine
Copy link

wealthmine commented Jul 14, 2016

Hi Marius,
I'm trying to import .zexp from Zope 2.5.1/Python 2.1.3 to Zope 2.13.24/Python 2.7.5. First error I've got was 'No module named TextIndex.Splitter.ZopeSplitter'. I hope mocking PluginIndexes may help. But where do you suggest to put the code that mocks it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment