nitesh
nitesh

Reputation: 266

Are Session variables present in Openerp

I'm trying to store a value gobally in my custom module.I'm making it as Gobal variable.But in form the gobal variable is not at all good.I want to store that variable in session. Can any one please tell me how to access Session variables in Openerp.Thanks in advance.

Upvotes: 1

Views: 923

Answers (2)

Jaykumar Patel
Jaykumar Patel

Reputation: 27614

In OpenERP you are use UID. this UID is define the current user session. For every time HTTP page routing _authenticate() method call.

This _authenticate() method is implemented in this path.

OpenERP/server/trunk/openerp/addons/base/ir/ir_http.py

Authenticate get using UID

def _authenticate(self, auth_method='user'):
    if request.session.uid:
        try:
            request.session.check_security()
            # what if error in security.check()
            #   -> res_users.check()
            #   -> res_users.check_credentials()
        except (openerp.exceptions.AccessDenied, openerp.http.SessionExpiredException):
            # All other exceptions mean undetermined status (e.g. connection pool full),
            # let them bubble up
            request.session.logout()
    getattr(self, "_auth_method_%s" % auth_method)()
    return auth_method

Upvotes: 3

Daniel Reis
Daniel Reis

Reputation: 13352

The solution may depend on why you need a global variable. But probably what you need is to use context:

A method can set a key/value in the current context and it will be passed along and made available to further methods. (The rule is for methods always pass along the context to other methods called by them).

Upvotes: 0

Related Questions