Review: Needs Fixing
Hello Yogesh,

I don't think this fix is right or sufficient. We should not fix the low-level 
functions like get_nice_size(), otherwise we will replicate this dict-aware 
code in many places.

The functions we use to post-process the field values should only be concerned 
about the value for one field, and should be very simple. 
The get() method should be the one doing this work: instead of directly 
processing the results depending on the type, it should first check if this is 
a multi result, and if it is, then handle each result in the appropriate manner 
according to its type.
Remember that a multi function can compute fields of different types.

The code for handling a multi-result and taking individual results in it should 
only be in one place, and then code for handling one result of a certain type 
should also only be in one place.

In pseudo-code:

def get(...):
    ....
    if is_multi:
       for field,value in result.iteritems():
           # post-process according to type of field
           result[id][field] = postprocess(obj.columns[field]._type,value)
    else:
       # post-process according to type of field
       result[id] = postprocess(self._type, result[id])

The pseudo-code is dumb but I hope this illustrates that the code for handling 
a multi-result dict is only in one place (get), and the code for 
post-processing the values is only in one place (here in a "postprocess" method 
that can do the right thing according to the type)

I hope is clear, otherwise don't hesitate to ask ;-)
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-781247-ysa/+merge/61933
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-bug-781247-ysa.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to