Merge lp:~acsone-openerp/openerp-connector/bug-1288187-sbi-unicode into lp:~openerp-connector-core-editors/openerp-connector/7.0

Proposed by Stéphane Bidoul (Acsone)
Status: Rejected
Rejected by: Guewen Baconnier @ Camptocamp
Proposed branch: lp:~acsone-openerp/openerp-connector/bug-1288187-sbi-unicode
Merge into: lp:~openerp-connector-core-editors/openerp-connector/7.0
Diff against target: 34 lines (+3/-3)
2 files modified
connector/queue/job.py (+2/-2)
connector/tests/test_job.py (+1/-1)
To merge this branch: bzr merge lp:~acsone-openerp/openerp-connector/bug-1288187-sbi-unicode
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Needs Information
Review via email: mp+209430@code.launchpad.net

Description of the change

Fix for jobs with unicode arguments.

Drawback is that it is not backward compatible with existing stored jobs.

What would be a better solution?

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi, the test that you provide success on my side. Was the test failing before you made your change?

review: Needs Information
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

I attached the test log to the bug.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks for the proposal. I'll try to find alternative ways to fix that.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Here is my first attempt to fix that: https://code.launchpad.net/~camptocamp/openerp-connector/7.0-unicode-pickled-1288187/+merge/209481

I think that using a binary field and avoiding conversions is better since pickled data is binary.
I still have to do some figure and figure out a way to migrate the existing jobs.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks Stéphane for your analysis of the issue and for proposing a patch!

I set this proposal as rejected as you acknowledged mine [0]

[0] https://code.launchpad.net/~camptocamp/openerp-connector/7.0-unicode-pickled-1288187/+merge/209481

Unmerged revisions

621. By Stéphane Bidoul (Acsone)

[FIX] jobs with unicode arguments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'connector/queue/job.py'
2--- connector/queue/job.py 2014-02-04 14:39:23 +0000
3+++ connector/queue/job.py 2014-03-05 11:38:03 +0000
4@@ -65,7 +65,7 @@
5 raised as `NotReadableJobError`).
6 """
7 try:
8- unpickled = loads(pickled.encode('utf-8'))
9+ unpickled = loads(pickled.decode('base64'))
10 except (StandardError, UnpicklingError):
11 raise NotReadableJobError('Could not unpickle.', pickled)
12 return unpickled
13@@ -212,7 +212,7 @@
14
15 vals['func'] = dumps((job.func_name,
16 job.args,
17- job.kwargs))
18+ job.kwargs)).encode('base64')
19
20 self.job_model.create(self.session.cr,
21 SUPERUSER_ID,
22
23=== modified file 'connector/tests/test_job.py'
24--- connector/tests/test_job.py 2014-01-13 16:07:35 +0000
25+++ connector/tests/test_job.py 2014-03-05 11:38:03 +0000
26@@ -127,7 +127,7 @@
27 eta = datetime.now() + timedelta(hours=5)
28 job = Job(func=dummy_task_args,
29 model_name='res.users',
30- args=('o', 'k'),
31+ args=(u'oé', 'k'),
32 kwargs={'c': '!'},
33 priority=15,
34 eta=eta,