تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
8 الردود
8344 أدوات العرض

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
يوليو 24
27623
10
يونيو 21
40255
1
مارس 18
9397
1
مارس 15
6257
0
مارس 15
4044