コンテンツへスキップ
メニュー
この質問にフラグが付けられました
8 返信
8452 ビュー

Am trying to track the visitor ip address ,but am failed to  implement it..please help me...Urgent.

アバター
破棄
最善の回答

Hi,

You can try the below code:

if "HTTP_X_FORWARDED_FOR" in request.httprequest.environ:
    # Virtual host
    ip = request.httprequest.environ["HTTP_X_FORWARDED_FOR"]
elif "HTTP_HOST" in request.httprequest.environ:
    # Non-virtualhost
    ip = request.httprequest.environ["REMOTE_ADDR"]


Hope this could helps

アバター
破棄
著作者

I got Exception 'object unbound'

Can you paste your code ..

著作者

from openerp.http import request

def git_ip():

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

著作者

from openerp.http import request

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

著作者

from openerp.http import request

def get_ip():

ipnew = request.httprequest.environ['REMOTE_ADDR']

return ipnew

May be you're missing @http.rout decorator. Btw from where you're calling your method ?

関連投稿 返信 ビュー 活動
7
7月 24
27814
10
6月 21
40451
1
3月 18
9442
1
3月 15
6338
0
3月 15
4116