[Erp5-dev] Monkey Patching problem

Jérome Perrin jerome at nexedi.com
Tue Sep 4 15:51:09 CEST 2007


Yes, monkey patching _is_ a problem :)

Łukasz Nowak a écrit :
> Hello,
> 
> I'd like to monkey patch Products.ERP5.Document.Resource file.
> 
> I've got my own product (Ventis), its contents are:
> 
> Ventis/
> Ventis/__init__.py:
> import ZopePatch
> Ventis/ZopePatch.py:
> from zLOG import LOG, INFO
> LOG('Ventis Patching',INFO,'Resouce Patch')
> from Products.Ventis.patches import ResourcePatch
> Ventis/patches/
> Ventis/patches/__init__.py (empty)
> Ventis/patches/ResourcePatch.py:
> from Products.ERP5.Document.Resource import Resource

When ERP5Type is initialized, it loads all documents from ERP5-like 
products by affecting them a dynamic path, everything is under ERP5Type 
product for forward compatibility (otherwise renaming a product or 
moving a document from one product to another is a nightmare).
Resource will be loaded as Products.ERP5Type.Document.Resource.Resource
but this is only after ERP5Type is initialized.

Jérome



More information about the Erp5-dev mailing list