From ab600268a740ba6a6c3974794dea9a780b7e334d Mon Sep 17 00:00:00 2001 From: Phuoc Cao Date: Sun, 2 Aug 2026 19:26:44 +0200 Subject: [PATCH] updated view_count --- cao_sunyata/views/blog.py | 11 +++++++---- setup.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cao_sunyata/views/blog.py b/cao_sunyata/views/blog.py index 902f3b1..c10fd9b 100644 --- a/cao_sunyata/views/blog.py +++ b/cao_sunyata/views/blog.py @@ -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] diff --git a/setup.py b/setup.py index 3a5780e..4dfa031 100644 --- a/setup.py +++ b/setup.py @@ -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',