Ir al contenido
Menú
Se marcó esta pregunta

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
Mejor respuesta

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
Mejor respuesta

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
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 24
2610
1
mar 15
4808
1
abr 24
6775
4
oct 21
37631
2
mar 15
5117