Context Management [As clients does]

Asked by Nhomar - Vauxoo

Hello.

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?

Regards.

Again: Good job.

Question information

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

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 :
#2

Hello i want wait for a little answer.
Hello!

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

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.search,
- OERP.read,
- OERP.write,
- OERP.unlink,
- OERP.report (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.: user.company_id.partner_id.name).

But there are no way to take the user's context into account when calling dynamic methods procured by "OERP.get('model.name')" 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 :
#4

ready, it works!

Thanks!..

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!

Regards.

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

Hi,

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 :
#6

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.

Regards