[Erp5-dev] portal_type is untrustable in initialization

Yoshinori Okuji yo at nexedi.com
Fri Jun 4 17:33:00 CEST 2004


I found that portal_type is not initialized when a factory method or a 
script is called to create a new object. More details can be found in 
my report:

http://collector.zope.org/CMF/248

Now ERP5Type/Document/Folder.py has a workaround for this problem. So 
you can use newContent safely, like this:

    d1_line1 = d1.newContent(id='1', portal_type=delivery_line_type,
                               resource='modele/004C401',
                               price=2.0,
                               quantity=1.0,
                               target_quantity=1.0)

But until this problem is fixed in CMF somehow, care is required when 
you write initialization code. For example, if you use scriptable type 
information for a portal type, you should be very careful about not 
using any method which depends on portal type information of a newly 
created object. A good example of this is getResourceValue because this 
kind of method uses acquisition_portal_type_list to acquire values from 
other objects (such as parent).

YO
-- 
Yoshinori Okuji, Nexedi Research Director
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
ERP5: Free / Open Source ERP Software for small and medium companies
http://www.erp5.org
Storever: OpenBrick, WiFi infrastructure, notebooks and servers
http://www.storever.com




More information about the Erp5-dev mailing list