[cpif] r89 - trunk/frontend-web
svn at argo.es
svn at argo.es
Wed May 23 21:19:07 CEST 2007
Author: alvaro
Date: Wed May 23 21:19:06 2007
New Revision: 89
Log:
Modificado el tratamiento de las urls
Modified:
trunk/frontend-web/skins.py
trunk/frontend-web/url_nuevo_usuario.py
Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py (original)
+++ trunk/frontend-web/skins.py Wed May 23 21:19:06 2007
@@ -17,6 +17,14 @@
'footer': 'footer.html'
}
+urls = {
+ '/': ['group_date', 'threads'],
+ '/hilo': ['thread_entries'],
+ '/nuevo_usuario': ['new_user'],
+ '/error': [],
+ '/stop': []
+ }
+
import os
sdir = os.path.join(os.path.curdir,"skins")
print "Inicializo los skins"
@@ -80,8 +88,8 @@
elif url[0] == "nuevo_usuario":
self._url="nuevo usuario"
else:
- self._url=""
print "Error" # FIXME
+ self._url="/%s" % url[0]
def load_dict(self,dict):
for key,val in dict.iteritems():
@@ -95,18 +103,19 @@
def thread_entries(self,e):
"""Format some entries inside a thread"""
- 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 }
- self.set_text(aux)
+ if "thread_entries" in urls[self._url]:
+ 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 }
+ self.set_text(aux)
def threads(self,t,notread,threads):
"""Format the thread list"""
# FIXME: No me gusta pasarle el array entero de hilos para hacer la busqueda de la fecha
- if self._url=="listado hilos":
+ if "threads" in urls[self._url]:
for thread,title,not_read in t:
format = self._style.pop(0)
self._style.append(format)
@@ -121,16 +130,18 @@
def group_date(self,date):
"""Insert the thread date"""
- if self._url=="listado hilos":
+ if "group_date" in urls[self._url]:
self.set_text(available_skins[self._skin]['group_date'] % {'group_date':date})
def body(self,title=None):
- if self._url=="listado hilos":
+ if "threads" in urls[self._url]:
aux = available_skins[self._skin]['body']
- elif self._url=="hilo":
+ elif "thread_entries" in urls[self._url]:
aux = available_skins[self._skin]['body_thread']
- elif self._url=="nuevo usuario":
+ elif "new_user" in urls[self._url]:
aux = available_skins[self._skin]['new_user']
+ elif "stop" in urls[self._url]:
+ aux = available_skins[self._skin]['generic']
else:
aux = available_skins[self._skin]['generic']
Modified: trunk/frontend-web/url_nuevo_usuario.py
==============================================================================
--- trunk/frontend-web/url_nuevo_usuario.py (original)
+++ trunk/frontend-web/url_nuevo_usuario.py Wed May 23 21:19:06 2007
@@ -9,7 +9,7 @@
pagina.load_dict({"page_title": "cpif - parando el servicio"})
if usuario!="master" :
- pagina.load_url("error")
+ pagina.load_url(["error"])
pagina.set_text("<h1>Solo el usuario 'master' puede dar de alta nuevos usuarios</h1>")
return (200,"text/html; charset=utf-8","\r\n".join([pagina.header(),pagina.body(),pagina.footer()]))
More information about the cpif
mailing list