Merge lp:~numerigraphe/openobject-server/trunk-bug525808-mutable-defaults into lp:openobject-server
- trunk-bug525808-mutable-defaults
- Merge into trunk
Proposed by
Numérigraphe
Status: | Merged |
---|---|
Merge reported by: | Vo Minh Thu |
Merged at revision: | not available |
Proposed branch: | lp:~numerigraphe/openobject-server/trunk-bug525808-mutable-defaults |
Merge into: | lp:openobject-server |
Diff against target: |
543 lines (+87/-47) 23 files modified
history/check_profile_l10n_all.py (+3/-1) openerp/addons/base/ir/ir_default.py (+1/-1) openerp/addons/base/ir/ir_filters.py (+1/-1) openerp/addons/base/ir/ir_model.py (+1/-1) openerp/addons/base/ir/ir_sequence.py (+1/-1) openerp/addons/base/ir/ir_translation.py (+1/-1) openerp/addons/base/ir/ir_ui_view.py (+2/-2) openerp/addons/base/ir/workflow/print_instance.py (+1/-1) openerp/addons/base/ir/workflow/workflow.py (+2/-2) openerp/addons/base/module/module.py (+1/-1) openerp/addons/base/res/ir_property.py (+1/-1) openerp/addons/base/res/res_bank.py (+3/-3) openerp/addons/base/res/res_company.py (+4/-4) openerp/addons/base/res/res_lang.py (+2/-2) openerp/addons/base/res/res_log.py (+1/-1) openerp/addons/base/res/res_partner.py (+15/-7) openerp/addons/base/res/res_request.py (+1/-1) openerp/report/render/rml2html/utils.py (+3/-1) openerp/report/render/rml2pdf/trml2pdf.py (+22/-8) openerp/report/render/rml2pdf/utils.py (+3/-1) openerp/report/render/rml2txt/rml2txt.py (+8/-4) openerp/report/render/rml2txt/utils.py (+3/-1) openerp/tools/safe_eval.py (+7/-1) |
To merge this branch: | bzr merge lp:~numerigraphe/openobject-server/trunk-bug525808-mutable-defaults |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+81464@code.launchpad.net |
Commit message
Description of the change
This branch replaces some mutable default values with None in report, base, safe_eval and history.
That should get us rid of the last bits of Bug #525808 in the server.
Lionel.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'history/check_profile_l10n_all.py' |
2 | --- history/check_profile_l10n_all.py 2011-09-26 00:54:44 +0000 |
3 | +++ history/check_profile_l10n_all.py 2011-11-07 15:51:24 +0000 |
4 | @@ -63,7 +63,9 @@ |
5 | time.sleep(3) |
6 | return True |
7 | |
8 | -def wizard_run(wizname, fieldvalues={}, endstate='end'): |
9 | +def wizard_run(wizname, fieldvalues=None, endstate='end'): |
10 | + if fieldvalues is None: |
11 | + fieldvalues = {} |
12 | wiz_id = sock4.create(dbname, uid, 'admin', wizname) |
13 | state = 'init' |
14 | datas = {'form':{}} |
15 | |
16 | === modified file 'openerp/addons/base/ir/ir_default.py' |
17 | --- openerp/addons/base/ir/ir_default.py 2009-10-20 10:52:23 +0000 |
18 | +++ openerp/addons/base/ir/ir_default.py 2011-11-07 15:51:24 +0000 |
19 | @@ -34,7 +34,7 @@ |
20 | 'company_id': fields.many2one('res.company','Company') |
21 | } |
22 | |
23 | - def _get_company_id(self, cr, uid, context={}): |
24 | + def _get_company_id(self, cr, uid, context=None): |
25 | res = self.pool.get('res.users').read(cr, uid, [uid], ['company_id'], context=context) |
26 | if res and res[0]['company_id']: |
27 | return res[0]['company_id'][0] |
28 | |
29 | === modified file 'openerp/addons/base/ir/ir_filters.py' |
30 | --- openerp/addons/base/ir/ir_filters.py 2011-08-06 00:50:46 +0000 |
31 | +++ openerp/addons/base/ir/ir_filters.py 2011-11-07 15:51:24 +0000 |
32 | @@ -53,7 +53,7 @@ |
33 | return False |
34 | return self.create(cr, uid, vals, context) |
35 | |
36 | - def _auto_init(self, cr, context={}): |
37 | + def _auto_init(self, cr, context=None): |
38 | super(ir_filters, self)._auto_init(cr, context) |
39 | # Use unique index to implement unique constraint on the lowercase name (not possible using a constraint) |
40 | cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_filters_name_model_uid_unique_index'") |
41 | |
42 | === modified file 'openerp/addons/base/ir/ir_model.py' |
43 | --- openerp/addons/base/ir/ir_model.py 2011-10-17 13:37:02 +0000 |
44 | +++ openerp/addons/base/ir/ir_model.py 2011-11-07 15:51:24 +0000 |
45 | @@ -161,7 +161,7 @@ |
46 | #pooler.restart_pool(cr.dbname) |
47 | return res |
48 | |
49 | - def instanciate(self, cr, user, model, context={}): |
50 | + def instanciate(self, cr, user, model, context=None): |
51 | class x_custom_model(osv.osv): |
52 | pass |
53 | x_custom_model._name = model |
54 | |
55 | === modified file 'openerp/addons/base/ir/ir_sequence.py' |
56 | --- openerp/addons/base/ir/ir_sequence.py 2011-10-07 14:54:06 +0000 |
57 | +++ openerp/addons/base/ir/ir_sequence.py 2011-11-07 15:51:24 +0000 |
58 | @@ -38,7 +38,7 @@ |
59 | ('code_unique', 'unique(code)', '`code` must be unique.'), |
60 | ] |
61 | |
62 | -def _code_get(self, cr, uid, context={}): |
63 | +def _code_get(self, cr, uid, context=None): |
64 | cr.execute('select code, name from ir_sequence_type') |
65 | return cr.fetchall() |
66 | |
67 | |
68 | === modified file 'openerp/addons/base/ir/ir_translation.py' |
69 | --- openerp/addons/base/ir/ir_translation.py 2011-09-13 17:43:10 +0000 |
70 | +++ openerp/addons/base/ir/ir_translation.py 2011-11-07 15:51:24 +0000 |
71 | @@ -62,7 +62,7 @@ |
72 | 'xml_id': fields.char('External ID', size=128, help='Maps to the ir_model_data for which this translation is provided.'), |
73 | } |
74 | |
75 | - def _auto_init(self, cr, context={}): |
76 | + def _auto_init(self, cr, context=None): |
77 | super(ir_translation, self)._auto_init(cr, context) |
78 | |
79 | # FIXME: there is a size limit on btree indexed values so we can't index src column with normal btree. |
80 | |
81 | === modified file 'openerp/addons/base/ir/ir_ui_view.py' |
82 | --- openerp/addons/base/ir/ir_ui_view.py 2011-09-19 22:48:50 +0000 |
83 | +++ openerp/addons/base/ir/ir_ui_view.py 2011-11-07 15:51:24 +0000 |
84 | @@ -109,7 +109,7 @@ |
85 | (view_id, model)) |
86 | return cr.fetchall() |
87 | |
88 | - def write(self, cr, uid, ids, vals, context={}): |
89 | + def write(self, cr, uid, ids, vals, context=None): |
90 | if not isinstance(ids, (list, tuple)): |
91 | ids = [ids] |
92 | result = super(view, self).write(cr, uid, ids, vals, context) |
93 | @@ -122,7 +122,7 @@ |
94 | |
95 | return result |
96 | |
97 | - def graph_get(self, cr, uid, id, model, node_obj, conn_obj, src_node, des_node,label,scale,context={}): |
98 | + def graph_get(self, cr, uid, id, model, node_obj, conn_obj, src_node, des_node, label, scale, context=None): |
99 | if not label: |
100 | label = [] |
101 | nodes=[] |
102 | |
103 | === modified file 'openerp/addons/base/ir/workflow/print_instance.py' |
104 | --- openerp/addons/base/ir/workflow/print_instance.py 2011-06-14 06:52:57 +0000 |
105 | +++ openerp/addons/base/ir/workflow/print_instance.py 2011-11-07 15:51:24 +0000 |
106 | @@ -210,7 +210,7 @@ |
107 | else: |
108 | return (False, False, False) |
109 | |
110 | - def create(self, cr, uid, ids, data, context={}): |
111 | + def create(self, cr, uid, ids, data, context=None): |
112 | self.obj = report_graph_instance(cr, uid, ids, data) |
113 | return (self.obj.get(), 'pdf') |
114 | |
115 | |
116 | === modified file 'openerp/addons/base/ir/workflow/workflow.py' |
117 | --- openerp/addons/base/ir/workflow/workflow.py 2011-09-19 22:48:50 +0000 |
118 | +++ openerp/addons/base/ir/workflow/workflow.py 2011-11-07 15:51:24 +0000 |
119 | @@ -45,7 +45,7 @@ |
120 | wf_service.clear_cache(cr, user) |
121 | return super(workflow, self).write(cr, user, ids, vals, context=context) |
122 | |
123 | - def get_active_workitems(self, cr, uid, res, res_id, context={}): |
124 | + def get_active_workitems(self, cr, uid, res, res_id, context=None): |
125 | |
126 | cr.execute('select * from wkf where osv=%s limit 1',(res,)) |
127 | wkfinfo = cr.dictfetchone() |
128 | @@ -212,7 +212,7 @@ |
129 | 'instance_id': fields.many2one('workflow.instance', 'Destination Instance', ondelete="cascade"), |
130 | 'workitem_id': fields.many2one('workflow.workitem', 'Workitem', required=True, ondelete="cascade"), |
131 | } |
132 | - def _auto_init(self, cr, context={}): |
133 | + def _auto_init(self, cr, context=None): |
134 | super(wkf_triggers, self)._auto_init(cr, context) |
135 | cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_triggers_res_id_model_index\'') |
136 | if not cr.fetchone(): |
137 | |
138 | === modified file 'openerp/addons/base/module/module.py' |
139 | --- openerp/addons/base/module/module.py 2011-10-05 14:23:15 +0000 |
140 | +++ openerp/addons/base/module/module.py 2011-11-07 15:51:24 +0000 |
141 | @@ -402,7 +402,7 @@ |
142 | } |
143 | |
144 | # update the list of available packages |
145 | - def update_list(self, cr, uid, context={}): |
146 | + def update_list(self, cr, uid, context=None): |
147 | res = [0, 0] # [update, add] |
148 | |
149 | known_mods = self.browse(cr, uid, self.search(cr, uid, [])) |
150 | |
151 | === modified file 'openerp/addons/base/res/ir_property.py' |
152 | --- openerp/addons/base/res/ir_property.py 2011-01-10 17:29:49 +0000 |
153 | +++ openerp/addons/base/res/ir_property.py 2011-11-07 15:51:24 +0000 |
154 | @@ -156,7 +156,7 @@ |
155 | return time.strftime('%Y-%m-%d', time.strptime(record.value_datetime, '%Y-%m-%d %H:%M:%S')) |
156 | return False |
157 | |
158 | - def get(self, cr, uid, name, model, res_id=False, context={}): |
159 | + def get(self, cr, uid, name, model, res_id=False, context=None): |
160 | domain = self._get_domain(cr, uid, name, model, context=context) |
161 | if domain is not None: |
162 | domain = [('res_id', '=', res_id)] + domain |
163 | |
164 | === modified file 'openerp/addons/base/res/res_bank.py' |
165 | --- openerp/addons/base/res/res_bank.py 2011-10-11 08:03:38 +0000 |
166 | +++ openerp/addons/base/res/res_bank.py 2011-11-07 15:51:24 +0000 |
167 | @@ -190,7 +190,7 @@ |
168 | res.append((val.id, result)) |
169 | return res |
170 | |
171 | - def onchange_company_id(self, cr, uid, ids, company_id, context={}): |
172 | + def onchange_company_id(self, cr, uid, ids, company_id, context=None): |
173 | result = {} |
174 | if company_id: |
175 | c = self.pool.get('res.company').browse(cr, uid, company_id, context=context) |
176 | @@ -201,7 +201,7 @@ |
177 | result = r |
178 | return result |
179 | |
180 | - def onchange_bank_id(self, cr, uid, ids, bank_id, context={}): |
181 | + def onchange_bank_id(self, cr, uid, ids, bank_id, context=None): |
182 | result = {} |
183 | if bank_id: |
184 | bank = self.pool.get('res.bank').browse(cr, uid, bank_id, context=context) |
185 | @@ -210,7 +210,7 @@ |
186 | return {'value': result} |
187 | |
188 | |
189 | - def onchange_partner_id(self, cr, uid, id, partner_id, context={}): |
190 | + def onchange_partner_id(self, cr, uid, id, partner_id, context=None): |
191 | result = {} |
192 | if partner_id: |
193 | part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) |
194 | |
195 | === modified file 'openerp/addons/base/res/res_company.py' |
196 | --- openerp/addons/base/res/res_company.py 2011-09-30 08:12:35 +0000 |
197 | +++ openerp/addons/base/res/res_company.py 2011-11-07 15:51:24 +0000 |
198 | @@ -148,7 +148,7 @@ |
199 | _sql_constraints = [ |
200 | ('name_uniq', 'unique (name)', 'The company name must be unique !') |
201 | ] |
202 | - def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context={}): |
203 | + def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context=None): |
204 | val = [] |
205 | if phone: val.append(_('Phone: ')+phone) |
206 | if fax: val.append(_('Fax: ')+fax) |
207 | @@ -201,7 +201,7 @@ |
208 | ids = self.search(cr, uid, [('parent_id','child_of',[company])]) |
209 | return ids |
210 | |
211 | - def _get_partner_hierarchy(self, cr, uid, company_id, context={}): |
212 | + def _get_partner_hierarchy(self, cr, uid, company_id, context=None): |
213 | if company_id: |
214 | parent_id = self.browse(cr, uid, company_id)['parent_id'] |
215 | if parent_id: |
216 | @@ -210,7 +210,7 @@ |
217 | return self._get_partner_descendance(cr, uid, company_id, [], context) |
218 | return [] |
219 | |
220 | - def _get_partner_descendance(self, cr, uid, company_id, descendance, context={}): |
221 | + def _get_partner_descendance(self, cr, uid, company_id, descendance, context=None): |
222 | descendance.append(self.browse(cr, uid, company_id).partner_id.id) |
223 | for child_id in self._get_company_children(cr, uid, company_id): |
224 | if child_id != company_id: |
225 | @@ -239,7 +239,7 @@ |
226 | self.cache_restart(cr) |
227 | return super(res_company, self).write(cr, *args, **argv) |
228 | |
229 | - def _get_euro(self, cr, uid, context={}): |
230 | + def _get_euro(self, cr, uid, context=None): |
231 | try: |
232 | return self.pool.get('res.currency').search(cr, uid, [])[0] |
233 | except: |
234 | |
235 | === modified file 'openerp/addons/base/res/res_lang.py' |
236 | --- openerp/addons/base/res/res_lang.py 2011-09-13 14:46:00 +0000 |
237 | +++ openerp/addons/base/res/res_lang.py 2011-11-07 15:51:24 +0000 |
238 | @@ -125,10 +125,10 @@ |
239 | return False |
240 | return True |
241 | |
242 | - def _get_default_date_format(self,cursor,user,context={}): |
243 | + def _get_default_date_format(self, cursor, user, context=None): |
244 | return '%m/%d/%Y' |
245 | |
246 | - def _get_default_time_format(self,cursor,user,context={}): |
247 | + def _get_default_time_format(self, cursor, user, context=None): |
248 | return '%H:%M:%S' |
249 | |
250 | _columns = { |
251 | |
252 | === modified file 'openerp/addons/base/res/res_log.py' |
253 | --- openerp/addons/base/res/res_log.py 2010-12-08 17:03:50 +0000 |
254 | +++ openerp/addons/base/res/res_log.py 2011-11-07 15:51:24 +0000 |
255 | @@ -41,7 +41,7 @@ |
256 | _order='create_date desc' |
257 | |
258 | _index_name = 'res_log_uid_read' |
259 | - def _auto_init(self, cr, context={}): |
260 | + def _auto_init(self, cr, context=None): |
261 | super(res_log, self)._auto_init(cr, context) |
262 | cr.execute('SELECT 1 FROM pg_indexes WHERE indexname=%s', |
263 | (self._index_name,)) |
264 | |
265 | === modified file 'openerp/addons/base/res/res_partner.py' |
266 | --- openerp/addons/base/res/res_partner.py 2011-10-11 16:34:35 +0000 |
267 | +++ openerp/addons/base/res/res_partner.py 2011-11-07 15:51:24 +0000 |
268 | @@ -98,7 +98,7 @@ |
269 | _order = 'name' |
270 | res_partner_title() |
271 | |
272 | -def _lang_get(self, cr, uid, context={}): |
273 | +def _lang_get(self, cr, uid, context=None): |
274 | obj = self.pool.get('res.lang') |
275 | ids = obj.search(cr, uid, [], context=context) |
276 | res = obj.read(cr, uid, ids, ['code', 'name'], context) |
277 | @@ -142,7 +142,9 @@ |
278 | 'color': fields.integer('Color Index'), |
279 | } |
280 | |
281 | - def _default_category(self, cr, uid, context={}): |
282 | + def _default_category(self, cr, uid, context=None): |
283 | + if context is None: |
284 | + context = {} |
285 | if 'category_id' in context and context['category_id']: |
286 | return [context['category_id']] |
287 | return [] |
288 | @@ -156,7 +158,9 @@ |
289 | 'color': 0, |
290 | } |
291 | |
292 | - def copy(self, cr, uid, id, default={}, context={}): |
293 | + def copy(self, cr, uid, id, default=None, context=None): |
294 | + if default is None: |
295 | + default = {} |
296 | name = self.read(cr, uid, [id], ['name'])[0]['name'] |
297 | default.update({'name': name+ _(' (copy)'), 'events':[]}) |
298 | return super(res_partner, self).copy(cr, uid, id, default, context) |
299 | @@ -182,10 +186,12 @@ |
300 | |
301 | # _constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])] |
302 | |
303 | - def name_get(self, cr, uid, ids, context={}): |
304 | + def name_get(self, cr, uid, ids, context=None): |
305 | + if context is None: |
306 | + context = {} |
307 | if not len(ids): |
308 | return [] |
309 | - if context and context.get('show_ref'): |
310 | + if context.get('show_ref', False): |
311 | rec_name = 'ref' |
312 | else: |
313 | rec_name = 'name' |
314 | @@ -224,7 +230,9 @@ |
315 | ids = ids[16:] |
316 | return True |
317 | |
318 | - def address_get(self, cr, uid, ids, adr_pref=['default']): |
319 | + def address_get(self, cr, uid, ids, adr_pref=None): |
320 | + if adr_pref is None: |
321 | + adr_pref = ['default'] |
322 | address_obj = self.pool.get('res.partner.address') |
323 | address_ids = address_obj.search(cr, uid, [('partner_id', 'in', ids)]) |
324 | address_rec = address_obj.read(cr, uid, address_ids, ['type']) |
325 | @@ -308,7 +316,7 @@ |
326 | 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner.address', context=c), |
327 | } |
328 | |
329 | - def name_get(self, cr, user, ids, context={}): |
330 | + def name_get(self, cr, user, ids, context=None): |
331 | if context is None: |
332 | context = {} |
333 | if not len(ids): |
334 | |
335 | === modified file 'openerp/addons/base/res/res_request.py' |
336 | --- openerp/addons/base/res/res_request.py 2011-01-11 05:08:59 +0000 |
337 | +++ openerp/addons/base/res/res_request.py 2011-11-07 15:51:24 +0000 |
338 | @@ -22,7 +22,7 @@ |
339 | from osv import osv, fields |
340 | import time |
341 | |
342 | -def _links_get(self, cr, uid, context={}): |
343 | +def _links_get(self, cr, uid, context=None): |
344 | obj = self.pool.get('res.request.link') |
345 | ids = obj.search(cr, uid, []) |
346 | res = obj.read(cr, uid, ids, ['object', 'name'], context) |
347 | |
348 | === modified file 'openerp/report/render/rml2html/utils.py' |
349 | --- openerp/report/render/rml2html/utils.py 2009-10-20 10:52:23 +0000 |
350 | +++ openerp/report/render/rml2html/utils.py 2011-11-07 15:51:24 +0000 |
351 | @@ -48,7 +48,9 @@ |
352 | def bool_get(value): |
353 | return (str(value)=="1") or (value.lower()=='yes') |
354 | |
355 | -def attr_get(node, attrs, dict={}): |
356 | +def attr_get(node, attrs, dict=None): |
357 | + if dict is None: |
358 | + dict = {} |
359 | res = {} |
360 | for name in attrs: |
361 | if node.get(name): |
362 | |
363 | === modified file 'openerp/report/render/rml2pdf/trml2pdf.py' |
364 | --- openerp/report/render/rml2pdf/trml2pdf.py 2011-11-04 15:57:59 +0000 |
365 | +++ openerp/report/render/rml2pdf/trml2pdf.py 2011-11-07 15:51:24 +0000 |
366 | @@ -226,7 +226,9 @@ |
367 | return style |
368 | |
369 | class _rml_doc(object): |
370 | - def __init__(self, node, localcontext, images={}, path='.', title=None): |
371 | + def __init__(self, node, localcontext, images=None, path='.', title=None): |
372 | + if images is None: |
373 | + images = {} |
374 | self.localcontext = localcontext |
375 | self.etree = node |
376 | self.filename = self.etree.get('filename') |
377 | @@ -311,7 +313,9 @@ |
378 | self.canvas.save() |
379 | |
380 | class _rml_canvas(object): |
381 | - def __init__(self, canvas, localcontext, doc_tmpl=None, doc=None, images={}, path='.', title=None): |
382 | + def __init__(self, canvas, localcontext, doc_tmpl=None, doc=None, images=None, path='.', title=None): |
383 | + if images is None: |
384 | + images = {} |
385 | self.localcontext = localcontext |
386 | self.canvas = canvas |
387 | self.styles = doc.styles |
388 | @@ -564,7 +568,9 @@ |
389 | tags[n.tag](n) |
390 | |
391 | class _rml_draw(object): |
392 | - def __init__(self, localcontext ,node, styles, images={}, path='.', title=None): |
393 | + def __init__(self, localcontext, node, styles, images=None, path='.', title=None): |
394 | + if images is None: |
395 | + images = {} |
396 | self.localcontext = localcontext |
397 | self.node = node |
398 | self.styles = styles |
399 | @@ -595,10 +601,12 @@ |
400 | |
401 | class _rml_flowable(object): |
402 | def __init__(self, doc, localcontext, images=None, path='.', title=None): |
403 | + if images is None: |
404 | + images = {} |
405 | self.localcontext = localcontext |
406 | self.doc = doc |
407 | self.styles = doc.styles |
408 | - self.images = images or {} |
409 | + self.images = images |
410 | self.path = path |
411 | self.title = title |
412 | self._logger = logging.getLogger('report.rml.flowable') |
413 | @@ -890,7 +898,9 @@ |
414 | self.canv._pageNumber = 0 |
415 | |
416 | class _rml_template(object): |
417 | - def __init__(self, localcontext, out, node, doc, images={}, path='.', title=None): |
418 | + def __init__(self, localcontext, out, node, doc, images=None, path='.', title=None): |
419 | + if images is None: |
420 | + images = {} |
421 | if not localcontext: |
422 | localcontext={'internal_header':True} |
423 | self.localcontext = localcontext |
424 | @@ -951,12 +961,12 @@ |
425 | fis.append(PageCount()) |
426 | self.doc_tmpl.build(fis) |
427 | |
428 | -def parseNode(rml, localcontext=None,fout=None, images=None, path='.',title=None): |
429 | - node = etree.XML(rml) |
430 | +def parseNode(rml, localcontext=None, fout=None, images=None, path='.', title=None): |
431 | if localcontext is None: |
432 | localcontext = {} |
433 | if images is None: |
434 | images = {} |
435 | + node = etree.XML(rml) |
436 | r = _rml_doc(node, localcontext, images, path, title=title) |
437 | #try to override some font mappings |
438 | try: |
439 | @@ -972,7 +982,11 @@ |
440 | r.render(fp) |
441 | return fp.getvalue() |
442 | |
443 | -def parseString(rml, localcontext = {},fout=None, images={}, path='.',title=None): |
444 | +def parseString(rml, localcontext=None, fout=None, images=None, path='.', title=None): |
445 | + if localcontext is None: |
446 | + localcontext = {} |
447 | + if images is None: |
448 | + images = {} |
449 | node = etree.XML(rml) |
450 | r = _rml_doc(node, localcontext, images, path, title=title) |
451 | |
452 | |
453 | === modified file 'openerp/report/render/rml2pdf/utils.py' |
454 | --- openerp/report/render/rml2pdf/utils.py 2011-11-04 16:42:22 +0000 |
455 | +++ openerp/report/render/rml2pdf/utils.py 2011-11-07 15:51:24 +0000 |
456 | @@ -179,7 +179,9 @@ |
457 | def bool_get(value): |
458 | return (str(value)=="1") or (value.lower()=='yes') |
459 | |
460 | -def attr_get(node, attrs, dict={}): |
461 | +def attr_get(node, attrs, dict=None): |
462 | + if dict is None: |
463 | + dict = {} |
464 | res = {} |
465 | for name in attrs: |
466 | if node.get(name): |
467 | |
468 | === modified file 'openerp/report/render/rml2txt/rml2txt.py' |
469 | --- openerp/report/render/rml2txt/rml2txt.py 2011-07-31 14:09:54 +0000 |
470 | +++ openerp/report/render/rml2txt/rml2txt.py 2011-11-07 15:51:24 +0000 |
471 | @@ -375,7 +375,7 @@ |
472 | return ';'.join(['%s:%s' % (x[0],x[1]) for x in self.style[tag].items()]) |
473 | |
474 | class _rml_template(object): |
475 | - def __init__(self, localcontext, out, node, doc, images={}, path='.', title=None): |
476 | + def __init__(self, localcontext, out, node, doc, images=None, path='.', title=None): |
477 | self.localcontext = localcontext |
478 | self.frame_pos = -1 |
479 | self.frames = [] |
480 | @@ -465,7 +465,7 @@ |
481 | return result |
482 | |
483 | class _rml_doc(object): |
484 | - def __init__(self, node, localcontext, images={}, path='.', title=None): |
485 | + def __init__(self, node, localcontext, images=None, path='.', title=None): |
486 | self.localcontext = localcontext |
487 | self.etree = node |
488 | self.filename = self.etree.get('filename') |
489 | @@ -495,14 +495,18 @@ |
490 | self.result += '\n' |
491 | out.write( self.result) |
492 | |
493 | -def parseNode(rml, localcontext = {},fout=None, images={}, path='.',title=None): |
494 | +def parseNode(rml, localcontext = {},fout=None, images=None, path='.',title=None): |
495 | + if images is None: |
496 | + images = {} |
497 | node = etree.XML(rml) |
498 | r = _rml_doc(node, localcontext, images, path, title=title) |
499 | fp = StringIO.StringIO() |
500 | r.render(fp) |
501 | return fp.getvalue() |
502 | |
503 | -def parseString(rml, localcontext = {},fout=None, images={}, path='.',title=None): |
504 | +def parseString(rml, localcontext = {},fout=None, images=None, path='.',title=None): |
505 | + if images is None: |
506 | + images = {} |
507 | node = etree.XML(rml) |
508 | r = _rml_doc(node, localcontext, images, path, title=title) |
509 | if fout: |
510 | |
511 | === modified file 'openerp/report/render/rml2txt/utils.py' |
512 | --- openerp/report/render/rml2txt/utils.py 2011-02-07 12:57:23 +0000 |
513 | +++ openerp/report/render/rml2txt/utils.py 2011-11-07 15:51:24 +0000 |
514 | @@ -112,7 +112,9 @@ |
515 | def bool_get(value): |
516 | return (str(value)=="1") or (value.lower()=='yes') |
517 | |
518 | -def attr_get(node, attrs, dict={}): |
519 | +def attr_get(node, attrs, dict=None): |
520 | + if dict is None: |
521 | + dict = {} |
522 | res = {} |
523 | for name in attrs: |
524 | if node.get(name): |
525 | |
526 | === modified file 'openerp/tools/safe_eval.py' |
527 | --- openerp/tools/safe_eval.py 2011-10-05 01:01:36 +0000 |
528 | +++ openerp/tools/safe_eval.py 2011-11-07 15:51:24 +0000 |
529 | @@ -212,7 +212,13 @@ |
530 | node_or_string = node_or_string.body |
531 | return _convert(node_or_string) |
532 | |
533 | -def _import(name, globals={}, locals={}, fromlist=[], level=-1): |
534 | +def _import(name, globals=None, locals=None, fromlist=None, level=-1): |
535 | + if globals is None: |
536 | + globals = {} |
537 | + if locals is None: |
538 | + locals = {} |
539 | + if fromlist is None: |
540 | + fromlist = [] |
541 | if name in _ALLOWED_MODULES: |
542 | return __import__(name, globals, locals, level) |
543 | raise ImportError(name) |