updated view_count
This commit is contained in:
@@ -35,16 +35,18 @@ def blog(request):
|
|||||||
|
|
||||||
# incrementer le compteur de vues
|
# incrementer le compteur de vues
|
||||||
client_addr = request.client_addr
|
client_addr = request.client_addr
|
||||||
today = datetime.datetime.now()
|
today_hour = datetime.datetime.now().strftime("%m/%d/%Y %H")
|
||||||
if entry.view_date :
|
if entry.view_date :
|
||||||
last_view = entry.view_date[:13]
|
last_view = entry.view_date[:13]
|
||||||
else:
|
else:
|
||||||
last_view = 'None'
|
last_view = 'None'
|
||||||
|
|
||||||
if client_addr != '127.0.0.1' and entry.view_ip != client_addr and last_view != str(today)[:13] and \
|
# import pdb;pdb.set_trace()
|
||||||
|
# if client_addr != '127.0.0.1' :
|
||||||
|
if entry.view_ip != client_addr or last_view != today_hour and \
|
||||||
request.user_agent.find("spider") == -1 and request.user_agent.find("crawler") == -1 and \
|
request.user_agent.find("spider") == -1 and request.user_agent.find("crawler") == -1 and \
|
||||||
request.user_agent.find("bot") == -1 and request.user_agent.find("+http") == -1:
|
request.user_agent.find("bot") == -1 and request.user_agent.find("+http") == -1:
|
||||||
update_view_counter(request, blog_id, client_addr, today)
|
update_view_counter(request, blog_id, client_addr, today_hour)
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -326,11 +328,12 @@ def maintenance(request):
|
|||||||
#
|
#
|
||||||
if 'form.submitted' in request.params:
|
if 'form.submitted' in request.params:
|
||||||
# lire le fichier logs.txt
|
# lire le fichier logs.txt
|
||||||
filename = os.path.join('/Users/phuoc/pyramid/cao_sunyata/', 'logs.txt')
|
filename = os.path.join('/Users/phuoc/pyramid/cao_sunyata/', 'access_sunyata.txt')
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
n = 0
|
n = 0
|
||||||
for line in f:
|
for line in f:
|
||||||
cols = line.split('|')
|
cols = line.split('|')
|
||||||
|
# import pdb;pdb.set_trace()
|
||||||
user_date = cols[0]
|
user_date = cols[0]
|
||||||
user_addr = cols[1]
|
user_addr = cols[1]
|
||||||
path = cols[2]
|
path = cols[2]
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ requires = [
|
|||||||
# 'pyramid_retry',
|
# 'pyramid_retry',
|
||||||
'pyramid_tm',
|
'pyramid_tm',
|
||||||
'SQLAlchemy==1.4.54',
|
'SQLAlchemy==1.4.54',
|
||||||
'transaction',
|
|
||||||
'zope.sqlalchemy==2.0', # last version supporting python 3.9
|
'zope.sqlalchemy==2.0', # last version supporting python 3.9
|
||||||
|
'transaction',
|
||||||
'webhelpers2', # various web building related helpers
|
'webhelpers2', # various web building related helpers
|
||||||
'passlib',
|
'passlib',
|
||||||
'python-magic',
|
'python-magic',
|
||||||
|
|||||||
Reference in New Issue
Block a user