odoo.http.request

The request object is a static object referring to the currently handled request, which contains everything you need in order to take action. The most important aspect here is the request.env property, which contains an Environment object that is just the same as self.env for models. This environment is bound to the current user, which is not in the preceding example, because we used auth='none'. The lack of a user is also why we have to sudo() all our calls to model methods in the example code.

If you're used to web development, you'll expect session handling, which is perfectly correct. Use request.session for an OpenERPSession object (which is quite a thin wrapper around the Session object of werkzeug), and request.session.sid to access the session ID. To store session values, just treat request.session as a dictionary, as shown in the following example:

request.session['hello'] = 'world' 
request.session.get('hello') 
Note that storing data in the session is no different from using global variables. Onlu use it if you must. This is usually the case for multi-request actions, such as a checkout in the website_sale module. In this case, tiy sgiykd handles all functionality concerning sessions in your controllers, never in your models.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset