Skip to Content
Menu
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
Discard
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
Discard
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
Discard
Related Posts Replies Views Activity
2
Jul 24
828
1
Mar 15
4031
1
Apr 24
5613
4
Oct 21
35813
2
Mar 15
4162