added black magic to detect the user when using http requests
bzr revid: nicolas.vanhoren@openerp.com-20130613162319-1w0renis7g2x5cw0
This commit is contained in:
parent
213a1a53a3
commit
5a22702043
|
@ -108,7 +108,7 @@ To use the database you must access the OpenERP models. The global ``request`` o
|
|||
|
||||
@http.httprequest
|
||||
def my_name(self):
|
||||
my_user_record = request.registry.get("res.users").browse(request.cr, request.uid, request.ui)
|
||||
my_user_record = request.registry.get("res.users").browse(request.cr, request.uid, request.uid)
|
||||
return "<h1>Your name is %s</h1>" % my_user_record.name
|
||||
|
||||
``request.registry`` is the registry that gives you access to the models. It is the equivalent of ``self.pool`` when
|
||||
|
|
|
@ -29,6 +29,7 @@ import werkzeug.exceptions
|
|||
import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
import werkzeug.wsgi
|
||||
import urllib2
|
||||
|
||||
import openerp
|
||||
|
||||
|
@ -97,7 +98,13 @@ class WebRequest(object):
|
|||
def init(self, params):
|
||||
self.params = dict(params)
|
||||
# OpenERP session setup
|
||||
self.session_id = self.params.pop("session_id", None) or uuid.uuid4().hex
|
||||
self.session_id = self.params.pop("session_id", None)
|
||||
if not self.session_id:
|
||||
i0 = self.httprequest.cookies.get("instance0|session_id", None)
|
||||
if i0:
|
||||
self.session_id = simplejson.loads(urllib2.unquote(i0))
|
||||
else:
|
||||
self.session_id = uuid.uuid4().hex
|
||||
self.session = self.httpsession.get(self.session_id)
|
||||
if not self.session:
|
||||
self.session = session.OpenERPSession()
|
||||
|
|
Loading…
Reference in New Issue