콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
21389 화면

I want to get Httprequest then get the client ip, but use below code in my module have a error. pls help, thanks very much

import openerp.addons.web.http as openerpweb
@openerpweb.jsonrequest
def get_ip_address(self, req):
    wsgienv = req.httprequest.environ
    env = dict(
         HTTP_HOST=wsgienv['HTTP_HOST'],
         REMOTE_ADDR=wsgienv['REMOTE_ADDR'],
     )
    _logger.log("env:%d", env)
    return True

Get Error:AttributeError: 'list' object has no attribute 'httprequest'

아바타
취소
베스트 답변

It looks like you call jsonrequest once and httprequest another time. I was able to install this code:
Note: I modified the 2nd line.

import openerp.addons.web.http as openerpweb
@openerpweb.httprequest
def get_ip_address(self, req):
    wsgienv = req.httprequest.environ
    env = dict(
               HTTP_HOST=wsgienv['HTTP_HOST'],
               REMOTE_ADDR=wsgienv['REMOTE_ADDR'],
               )
    #_logger.log("eng:%d",env)
    return True

I didn't import logger.
What URL are you calling to access your function?

아바타
취소
베스트 답변

sorry for asking question here.  i am not able create object of http request in my own module.

xml:

    <record id="lead_sample" model="ir.ui.view">
        <field name="name">Clients</field>
        <field name="model">document.download</field>
        <field name="arch" type="xml">
            <form string="lead">
                <field name="name"/>
                <button type="action" name="download" string="Downloads" class="oe_button oe_highlight"/>
            </form>
        </field>
    </record>

python:

@openerpweb.httprequest
 def download(self, cr, uid, req, token):       
        return req.make_response(open('/home/cryosave_qrcodes/091_14_00336.png').read,
           [('Content-Type', 'application/octet-stream; charset=binary'),
           ('Content-Disposition', content_disposition('filename.png', req))],
           {'fileToken': token}
        )

I have created this code but i don't know how to create http reqest object in my module

아바타
취소
관련 게시물 답글 화면 활동
0
8월 22
2486
1
3월 15
3960
0
3월 23
2120
4
2월 23
43552
1
6월 22
5399