[cpif] r95 - in trunk: backend frontend-web

svn at argo.es svn at argo.es
Thu May 24 15:46:43 CEST 2007


Author: jcea
Date: Thu May 24 15:46:42 2007
New Revision: 95

Log:
Todas las fechas en castellano, referenciadas a
la zona horaria de Madrid.



Modified:
   trunk/backend/database.py
   trunk/frontend-web/calendario.py
   trunk/frontend-web/skins.py
   trunk/frontend-web/url_.py
   trunk/frontend-web/url_hilo.py

Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py	(original)
+++ trunk/backend/database.py	Thu May 24 15:46:42 2007
@@ -14,7 +14,12 @@
     version=root.get("version del foro",None)
     if version==VERSION_DB : return
     if version :
-      raise RuntimeError("Version incompatible de la base de datos")
+      import upgrade
+      upgrade.do(conn)
+      version=root.get("version del foro",None)
+      if version==VERSION_DB : return
+      if version :
+        raise RuntimeError("Version incompatible de la base de datos")
 
     root["version del foro"]=VERSION_DB
 

Modified: trunk/frontend-web/calendario.py
==============================================================================
--- trunk/frontend-web/calendario.py	(original)
+++ trunk/frontend-web/calendario.py	Thu May 24 15:46:42 2007
@@ -26,3 +26,12 @@
     cache_meses[fecha]=mes
   return mes %{"usuario":usuario}
 
+def daydate(ts,tz) :
+  import datetime
+  dt=datetime.datetime.fromtimestamp(ts,tz)
+  return "%d de %s de %d" %(dt.day,nombres_meses[dt.month],dt.year)
+
+def hourdate(ts,tz) :
+  import datetime
+  dt=datetime.datetime.fromtimestamp(ts,tz)
+  return "%d de %s de %d, a las %.2d:%.2d" %(dt.day,nombres_meses[dt.month],dt.year,dt.hour,dt.minute)

Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py	(original)
+++ trunk/frontend-web/skins.py	Thu May 24 15:46:42 2007
@@ -2,6 +2,12 @@
 
 import globales
 
+from calendario import daydate,hourdate
+
+meses=["","enero","febrero","marzo","abril",
+          "mayo","junio","julio","agosto",
+          "septiembre","octubre","noviembre","diciembre"]
+
 available_skins = {}
 
 skin_files = {
@@ -49,6 +55,8 @@
   _text = []
 
   def __init__(self):
+    import pytz
+    self._tz=pytz.timezone("Europe/Madrid")
     self._skin="default"
     self._url=""
     self.reset()
@@ -108,9 +116,9 @@
       for msg_num,author,date,text in e:
         format = self._style.pop(0)
         self._style.append(format)
-
-        import time
-        aux = available_skins[self._skin]['thread_entry'] % {"msg_num":msg_num, "author":author, "date":time.ctime(date), "text":text,"format":format }
+        aux = available_skins[self._skin]['thread_entry'] % {"msg_num":msg_num, "author":author,
+                "date":hourdate(date,self._tz),
+                "text":text,"format":format }
         self.set_text(aux)
 
   def threads(self,t,notread,threads):
@@ -121,18 +129,17 @@
         format = self._style.pop(0)
         self._style.append(format)
 
-        import time
-        ts_created=time.ctime(threads[thread]["TS"])
+        ts=threads[thread]["TS"]
         if not_read:
-          aux = available_skins[self._skin]['thread_unread'] % {"title":title,"thread":thread,"t_date":ts_created,"format": format,"notread":notread[thread]}
+          aux = available_skins[self._skin]['thread_unread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format,"notread":notread[thread]}
         else:
-          aux = available_skins[self._skin]['thread'] % {"title":title,"thread":thread,"t_date":ts_created,"format": format}
+          aux = available_skins[self._skin]['thread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format}
         self.set_text(aux)
   
   def group_date(self,date):
     """Insert the thread date"""
     if "group_date" in urls[self._url]:
-      self.set_text(available_skins[self._skin]['group_date'] % {'group_date':date})
+      self.set_text(available_skins[self._skin]['group_date'] % {'group_date':daydate(date,self._tz)})
 
   def body(self,title=None):
     if "threads" in urls[self._url]:

Modified: trunk/frontend-web/url_.py
==============================================================================
--- trunk/frontend-web/url_.py	(original)
+++ trunk/frontend-web/url_.py	Thu May 24 15:46:42 2007
@@ -8,10 +8,6 @@
 delta_dia=datetime.timedelta(1)
 medianoche=datetime.time(0)
 
-meses=["","enero","febrero","marzo","abril",
-          "mayo","junio","julio","agosto",
-          "septiembre","octubre","noviembre","diciembre"]
-
 # La fecha del hilo modificado hace mas tiempo
 fecha_min=None
 
@@ -61,7 +57,7 @@
     h=database.listado_hilos_personal(conn,usuario,ts,ts2)
     l=len(h)
     if l :
-      pagina.group_date("%d de %s de %d" %(fecha.day,meses[fecha.month],fecha.year))
+      pagina.group_date(ts2)
       num_hilos+=l
       pagina.threads(h,punto_no_leido,hilos)
     ts=ts2

Modified: trunk/frontend-web/url_hilo.py
==============================================================================
--- trunk/frontend-web/url_hilo.py	(original)
+++ trunk/frontend-web/url_hilo.py	Thu May 24 15:46:42 2007
@@ -4,7 +4,7 @@
 
 @monitor
 def gestiona_url(conn,handler,path,usuario) :
-  import time,database
+  import time,database,calendario
   try :
     hilo_num=int(path[-1])
   except :
@@ -20,7 +20,7 @@
 
   pagina.load_dict({
       "thread_title": "Hilo: %s (%s)" %(meta["titulo"],meta["creador"]),
-      "thread_date": "%s" %time.ctime(meta["TS creacion"]),
+      "thread_date": calendario.hourdate(meta["TS creacion"],pagina._tz), # FIXME: esto es un fallo de encapsulamiento
       "msg_num": hilo_num
       })
   pagina.thread_entries(mensajes)



More information about the cpif mailing list