[cpif] r262 - in trunk: . backend frontend-web
svn at argo.es
svn at argo.es
Wed Jul 11 22:26:23 CEST 2007
Author: jcea
Date: Wed Jul 11 22:26:22 2007
New Revision: 262
Log:
Los ficheros 'static' tienen 'last-modified'
Modified:
trunk/TODO
trunk/backend/database.py
trunk/backend/upgrade.py
trunk/frontend-web/url_static.py
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Wed Jul 11 22:26:22 2007
@@ -233,10 +233,6 @@
Basta con comprobar que es el mismo servidor y, si no es
asi, se manda al usuario a la pagina principal.
-- 20070703: FRONTAL WEB: Los objetos estaticos deberian
- tener un "last-modified", y verificarlo en las peticiones
- condicionales, en beneficio de herramientas como "wget".
-
- 20070704: FRONTAL WEB: Cuando integramos los smileys en los
mensajes, habria que ponerles tambien las dimensiones X/Y.
@@ -247,4 +243,10 @@
- 20070711: FRONTAL WEB: Definir urls a autorizar. Discutir el
escapado de get_msg_source (necesario?)
+
+- 20070711: FRONTAL WEB: Cuando nos hacen una peticion condicional
+ con "if-modified-since" (por ejemplo, a los objetos estaticos),
+ verificarlos tambien para poder devolver un 304 cuando sea posible.
+
+ Esto es especialmente interesante con herramientas como "wget".
Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py (original)
+++ trunk/backend/database.py Wed Jul 11 22:26:22 2007
@@ -1,7 +1,7 @@
# $Id$
-VERSION_DB="2007070402"
+VERSION_DB="2007071101"
from globales import thread_len
@@ -107,12 +107,25 @@
return metadata
def save_static(conn,section,data,metadata,update=False) :
+ def date_now() :
+ import time
+ weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+ monthname = [None,
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ year, month, day, hh, mm, ss, wd, y, z = time.gmtime()
+ s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
+ weekdayname[wd],
+ day, monthname[month], year,
+ hh, mm, ss)
+
from durus.persistent_list import PersistentList
root=conn.get_root()
import md5
hash=md5.new(data).hexdigest()
d=root["static"][section]
if (hash not in d) or update :
+ metadata["last modified"]=date_now()
d[hash]=(metadata,PersistentList([data]))
return hash
Modified: trunk/backend/upgrade.py
==============================================================================
--- trunk/backend/upgrade.py (original)
+++ trunk/backend/upgrade.py Wed Jul 11 22:26:22 2007
@@ -139,3 +139,22 @@
root["smileys"]=PersistentList()
conn.commit()
+ if root["version del foro"]=="2007070402" :
+ import time
+ weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+ monthname = [None,
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ year, month, day, hh, mm, ss, wd, y, z = time.gmtime()
+ s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
+ weekdayname[wd],
+ day, monthname[month], year,
+ hh, mm, ss)
+ print "Actualizando la base de datos: 2007070402 -> 2007071101"
+ root["version del foro"]="2007071101"
+ for i in root["static"].values() :
+ for j in i.values() :
+ j[0]["last modified"]=ts
+ conn.commit()
+
+
Modified: trunk/frontend-web/url_static.py
==============================================================================
--- trunk/frontend-web/url_static.py (original)
+++ trunk/frontend-web/url_static.py Wed Jul 11 22:26:22 2007
@@ -14,6 +14,7 @@
metadata,data=data
data=data[0] # de-encapsulate
+ headers["Last-Modified"]=metadata["last modified"]
if handler.headers.get("if-none-match")==etag :
return (304,headers,"")
More information about the cpif
mailing list