Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
8 Odpovědi
8840 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor

I got Exception 'object unbound'

Can you paste your code ..

Autor

from openerp.http import request

def git_ip():

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

return ipnew

Autor

from openerp.http import request

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

return ipnew

Autor

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 ?

Related Posts Odpovědi Zobrazení Aktivita
7
čvc 24
28424
10
čvn 21
41222
1
bře 18
9771
1
bře 15
6742
0
bře 15
4459