updated view_count

This commit is contained in:
2026-08-02 19:26:44 +02:00
parent 7b686b9e27
commit ab600268a7
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -35,16 +35,18 @@ def blog(request):
# incrementer le compteur de vues
client_addr = request.client_addr
today = datetime.datetime.now()
today_hour = datetime.datetime.now().strftime("%m/%d/%Y %H")
if entry.view_date :
last_view = entry.view_date[:13]
else:
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("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 {
@@ -326,11 +328,12 @@ def maintenance(request):
#
if 'form.submitted' in request.params:
# 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:
n = 0
for line in f:
cols = line.split('|')
# import pdb;pdb.set_trace()
user_date = cols[0]
user_addr = cols[1]
path = cols[2]
+1 -1
View File
@@ -18,8 +18,8 @@ requires = [
# 'pyramid_retry',
'pyramid_tm',
'SQLAlchemy==1.4.54',
'transaction',
'zope.sqlalchemy==2.0', # last version supporting python 3.9
'transaction',
'webhelpers2', # various web building related helpers
'passlib',
'python-magic',