Discussion:
[Erp5-dev] portal_type is untrustable in initialization
Yoshinori Okuji
2004-06-04 15:33:00 UTC
Permalink
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
Yoshinori Okuji
2004-06-07 13:55:07 UTC
Permalink
Post by Yoshinori Okuji
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
http://collector.zope.org/CMF/248
Now I feel that it is a waste of time to discuss this with them. Their
attitude is " do not want to change anything unless backward
compatibility is perfectly reserved ". I don't think this can be fixed
with no risk on backward compatibility. And, clearly enough, ERP5 is
one of few CMF-based projects which are really complex and dynamic. So
most people don't need to fix this problem.

Thus I think a better way would be:

- Fix this by a dynamic patch

or

- Make a new type information class for ERP5

I will choose the former one at the moment.

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