Skip to Content
Menú
This question has been flagged

I am writing an application to service Dropbox webhooks and I have a controller class:

class webhook(http.Controller):

   _cp_path="/pathto"

   @http.request

   def index(self, req, **kwargs):

      """Need to access database tables here"""

 

So I figured out that I need a cr, uid, and some other parameters,

I defined the following and have gotten it to work:

 

cr = openerp.sql_db.db_connect("DBNAME").cursor()

pool=openerp.pooler.RegistryManager.get("DBNAME")

result=pool.get("model.path").search(cr,1,[])

cr.close()

 

Is this the best way to do this?

Avatar
Descartar
Best Answer

Hi !

As said in 

https://www.odoo.com/documentation/8.0/howtos/website.html#accessing-the-data

you can acces you models with:

http.request.env['your.model']

Regards

Avatar
Descartar
Best Answer

Hi, I'm writing a controller for V7 and I have the same problem. I want to get the database name and the cursor but I can't because there is no a "request" parameter like in V8 to get the cr value and I can't obtain database name from anywhere. Is it possible to do it in anyway?

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de jul. 24
2607
1
de març 15
4803
1
d’abr. 24
6771
4
d’oct. 21
37630
2
de març 15
5115