Discussion:
[Erp5-dev] [Erp5-report] r35117 seb - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Robin Sébastien
2010-05-07 17:35:47 UTC
Permalink
Salut Nicolas,

Apr?s un moment de gal?re, j'ai fini par trouver le bug tr?s bizarre
qui ne se d?clenche que quand on a plein de BT (comme dans TSXX).
Author: seb
Date: Fri May 7 19:28:20 2010
New Revision: 35117
URL: http://svn.erp5.org?rev=35117&view=rev
Installation of business template was failing when the number of
installed business template was big enough.
Parsing a dict in a loop and calling update every time (even if
keys are not changed) seems to be not reliable and this ends up
calling 2 times the same code for the same key.
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=35117&r1=35116&r2=35117&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Fri May 7 19:28:20 2010
@@ -1907,9 +1907,8 @@
# each portal type
(default_chain, chain_dict) = getChainByType(context)
# First convert all workflow_ids into list.
- chain_dict.update({key: chain_dict[key].\
- split(self._chain_string_separator)})
+ chain_dict[key] = value.split(self._chain_string_separator)
# Set the default chain to the empty string is probably the
# best solution, by default it is 'default_workflow', which is
# not very usefull
@@ -1966,9 +1965,8 @@
, portal_type))
chain_dict[chain_key] = self._objects[path]
# convert workflow list into string only at the end.
- chain_dict.update({key: self._chain_string_separator.\
- join(chain_dict[key])})
+ chain_dict[key] = self._chain_string_separator.join(value)
context.portal_workflow.manage_changeWorkflows(default_chain,
props=chain_dict)
Avec ton code, cette deuxi?me boucle pouvait donner :

...
'chain_Sale Supply Line': 'e, d, i, t, _, w, o, r, k, f, l, o, w, ,, , s, u, p, p, l, y, _, l, i, n, e, _, i, n, t, e, r, a, c, t, i, o, n, _, w, o, r, k, f, l, o, w',
'chain_Sale Supply Module': '(Default)',
'chain_Sale Trade Condition': 'edit_workflow, security_interaction_workflow, sale_trade_condition_workflow, trade_model_line_parent_interaction_workflow',
...

Par ailleurs, il est mieux d'utiliser des itervalues ou iterkeys
ou iteritems quand on parcourt un dictionnaire. Ca permet d'?conomiser
la m?moire car toute la liste n'est pas ?valu?e en un seul coup, elle
est juste parcourue avec un iterator.


@+

Seb.
_______________________________________________
Erp5-report mailing list
Erp5-report at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-report
Robin Sébastien
2010-05-10 07:18:09 UTC
Permalink
Hello,

Sorry, I didn't want to send email to mailing list.

Seb.
Post by Robin Sébastien
Salut Nicolas,
Apr?s un moment de gal?re, j'ai fini par trouver le bug tr?s bizarre
qui ne se d?clenche que quand on a plein de BT (comme dans TSXX).
Author: seb
Date: Fri May 7 19:28:20 2010
New Revision: 35117
URL: http://svn.erp5.org?rev=35117&view=rev
Installation of business template was failing when the number of
installed business template was big enough.
Parsing a dict in a loop and calling update every time (even if
keys are not changed) seems to be not reliable and this ends up
calling 2 times the same code for the same key.
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=35117&r1=35116&r2=35117&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Fri May 7 19:28:20 2010
@@ -1907,9 +1907,8 @@
# each portal type
(default_chain, chain_dict) = getChainByType(context)
# First convert all workflow_ids into list.
- chain_dict.update({key: chain_dict[key].\
- split(self._chain_string_separator)})
+ chain_dict[key] = value.split(self._chain_string_separator)
# Set the default chain to the empty string is probably the
# best solution, by default it is 'default_workflow', which is
# not very usefull
@@ -1966,9 +1965,8 @@
, portal_type))
chain_dict[chain_key] = self._objects[path]
# convert workflow list into string only at the end.
- chain_dict.update({key: self._chain_string_separator.\
- join(chain_dict[key])})
+ chain_dict[key] = self._chain_string_separator.join(value)
context.portal_workflow.manage_changeWorkflows(default_chain,
props=chain_dict)
...
'chain_Sale Supply Line': 'e, d, i, t, _, w, o, r, k, f, l, o, w, ,, , s, u, p, p, l, y, _, l, i, n, e, _, i, n, t, e, r, a, c, t, i, o, n, _, w, o, r, k, f, l, o, w',
'chain_Sale Supply Module': '(Default)',
'chain_Sale Trade Condition': 'edit_workflow, security_interaction_workflow, sale_trade_condition_workflow, trade_model_line_parent_interaction_workflow',
...
Par ailleurs, il est mieux d'utiliser des itervalues ou iterkeys
ou iteritems quand on parcourt un dictionnaire. Ca permet d'?conomiser
la m?moire car toute la liste n'est pas ?valu?e en un seul coup, elle
est juste parcourue avec un iterator.
@+
Seb.
_______________________________________________
Erp5-report mailing list
Erp5-report at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-report
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-dev
Loading...