Using multiple zope2 product directories from python scriptsΒΆ
Having fun with the python documentation generation tool sphinx today. I halfway hooked it up in my buildout, so I have a bin/sphinx-build script with all the eggs and python paths linked in.
Boom, semi-automatic python docstring extraction failed with an import error (on Products.statusmessages, Products.Archetypes, etc.). Aha, those are not in the Products/ dir in parts/zope2/lib/python (which is linked) but in parts/plone/*. It took me quite some time, but in the end (after looking at zope's own code) I added the following near the top of my sphinx conf.py config file:
import Products
# ^^^ From zope's lib/python.
Products.__path__.append(os.path.abspath('../../parts/plone'))
# ^^^ Relative path in my situation.
I did not know that individual modules also had a path, I only knew about sys.path. It works :-)