[Erp5-dev] Monkey Patching problem

Łukasz Nowak lukasz.nowak at ventis.com.pl
Tue Sep 4 16:06:31 CEST 2007


Hello,

On 2007-09-04, 15:51:09
Jérome Perrin <jerome at nexedi.com> wrote:

> 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.

So... shall I do from Products.ERP5Type.Document.Resource import
Resource? It is not working (ImportError: No module named Resource). So
clue is in "but this is only after ERP5Type is initialized." - how
wait/hook into it? Any code snippet to achieve it?

Thanks,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...''



More information about the Erp5-dev mailing list