[Erp5-dev] [Erp5-report] r35117 seb - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Robin Sébastien
seb at nexedi.com
Mon May 10 09:18:09 CEST 2010
Hello,
Sorry, I didn't want to send email to mailing list.
Seb.
On 07/05/10 19:35, Robin Sébastien wrote:
> 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).
>
> Pour ton info, j'ajoute un commentaire ci-dessous dans le patch :
>
> On 07/05/10 19:28, nobody at svn.erp5.org wrote:
>> Author: seb
>> Date: Fri May 7 19:28:20 2010
>> New Revision: 35117
>>
>> URL: http://svn.erp5.org?rev=35117&view=rev
>> Log:
>> 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.
>>
>> Modified:
>> 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.
>> - for key in chain_dict:
>> - chain_dict.update({key: chain_dict[key].\
>> - split(self._chain_string_separator)})
>> + for key, value in chain_dict.iteritems():
>> + 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.
>> - for key in chain_dict:
>> - chain_dict.update({key: self._chain_string_separator.\
>> - join(chain_dict[key])})
>> + for key, value in chain_dict.iteritems():
>> + 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
>
> _______________________________________________
> Erp5-dev mailing list
> Erp5-dev at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-dev
More information about the Erp5-dev
mailing list