Context Management [As clients does]

Asked by Nhomar - Vauxoo


Im using this library to manage an external graphical tool for a real particular feature.

I want to know : Do yo consider the ability to send CONTEXT={} as clients does?, if not, Where do you think it should be done to make it and propose you the MP?


Again: Good job.

Question information

English Edit question
OERPLib Edit question
No assignee Edit question
Solved by:
Nhomar - Vauxoo
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Nhomar - Vauxoo (nhomar) said :

Hello i want wait for a little answer.

Revision history for this message
Sébastien Alix (sebastien-alix) said :

Hello! (bis),

Currently the user's context is not propagated when executing a query. It's possible to implement this feature only for the following methods:
- OERP.browse,
- OERP.write,
- OERP.unlink,
- (its partially done for report method),

... as they are hardcoded in OERPLib, and as such we control keyword arguments:

    >>> oerp.write('res.users', [1], {}, context={'lang': 'en_US'}) # Works! OERP.write is hardcoded

And so, when using these methods, le context could be propagated automatically. Some works has to be done however (in particular 'browse', to retrieve the context when browing relations from another relation, e.g.:

But there are no way to take the user's context into account when calling dynamic methods procured by "OERP.get('')" OSV interface (XML/NET-RPC do not provide sufficient data to know arguments of a method, and even less their order).

    >>> oerp.get('res.users').write([1], {}, context={'lang': 'en_US'}) # Doesn't work
    TypeError: rpc_method() got an unexpected keyword argument 'context'

Hoping this helps you.

Revision history for this message
Nhomar - Vauxoo (nhomar) said :

ready, it works!


IMHO, what is happend with res.users have 2 point of views.

1.- Is a Bug, badmanage of the NO context for security!
2.- Is a leak of functionality.

BTW, let see what i can do for make it generical wnought!


Revision history for this message
Sébastien Alix (sebastien-alix) said :


Sorry, I didn't understand your question... What do you mean by "have 2 point of views"?

For my part I'm thinking about an elegant solution to support user context for OSV main methods like 'read', 'write', etc (and easily expandable if the method signatures change in future versions of OpenERP/OpenObject).

Revision history for this message
Sébastien Alix (sebastien-alix) said :

Hi Nhomar,
I come back about this (context management), I was wrong, it can be done indeed. I currently work on it and prepare a 0.7 version which will support that.