[cpif] r271 - in trunk: . backend frontend-web frontend-web/skins/default
svn at argo.es
svn at argo.es
Thu Jul 12 18:15:49 CEST 2007
Author: jcea
Date: Thu Jul 12 18:15:47 2007
New Revision: 271
Log:
Primeros pasos para el soporte de correo electronico
Modified:
trunk/TODO
trunk/backend/database.py
trunk/backend/upgrade.py
trunk/frontend-web/parsers.py
trunk/frontend-web/skins/default/body_new_user.html
trunk/frontend-web/skins/default/body_show_thread.html
trunk/frontend-web/url_nuevo_usuario_POST.py
trunk/frontend-web/url_perfil.py
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Thu Jul 12 18:15:47 2007
@@ -250,3 +250,8 @@
Esto es especialmente interesante con herramientas como "wget".
+- 20070711: FRONTAL WEB: Los parsers HTML y BBCode (no se si alguno mas)
+ devuelven tokens vacios ('') cuando estan procesando un mensaje
+ a publicar, si los tags estan juntos, el texto empieza con un
+ tag. Hacer limpieza.
+
Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py (original)
+++ trunk/backend/database.py Thu Jul 12 18:15:47 2007
@@ -1,7 +1,7 @@
# $Id$
-VERSION_DB="2007071104"
+VERSION_DB="2007071201"
from globales import thread_len
@@ -213,7 +213,7 @@
old_OpenIDs.clear() # Este tipo es persistente, asi que lo reutilizamos
old_OpenIDs.update(OpenIDs)
-def usuario_add(conn,nick,datos,clave=None,OpenIDs=set()) :
+def usuario_add(conn,nick,datos,clave=None,email="",OpenIDs=set()) :
from durus.btree import BTree
from durus.persistent_dict import PersistentDict
from durus.persistent_set import PersistentSet
@@ -246,6 +246,7 @@
"datos":datos,
"clave":clave,
"OpenID":PersistentSet(OpenIDs),
+ "email":email,
"cookie":None,
"nick":nick})
Modified: trunk/backend/upgrade.py
==============================================================================
--- trunk/backend/upgrade.py (original)
+++ trunk/backend/upgrade.py Thu Jul 12 18:15:47 2007
@@ -173,3 +173,12 @@
i[j]=k # Los items son diccionarios no persistentes, asi que hay que sobreescribir
conn.commit()
+ if root["version del foro"]=="2007071104" :
+ print "Actualizando la base de datos: 2007071104 -> 2007071201"
+ root["version del foro"]="2007071201"
+ for usuario in root["usuarios"]["usuarios"].itervalues() :
+ usuario["email"]=""
+ if "jcea" in root["usuarios"]["usuarios"] :
+ root["usuarios"]["usuarios"]["jcea"]["email"]="jcea at argo.es"
+ conn.commit()
+
Modified: trunk/frontend-web/parsers.py
==============================================================================
--- trunk/frontend-web/parsers.py (original)
+++ trunk/frontend-web/parsers.py Thu Jul 12 18:15:47 2007
@@ -13,9 +13,11 @@
tokens = [(True, text, None)]
- parsers = [
+ parsers_first = [
(allow_html, parser_html),
(allow_bbcode, parser_bbcode),
+ ]
+ parsers_last = [
(True, parser_urls),
(True, parser_smileys),
(True, parser_eol),
@@ -24,7 +26,41 @@
(True, parser_entities)
]
- for allow, parser in parsers:
+ aux=[]
+ while tokens :
+ token=tokens.pop(0)
+ must_reparse,fragment,curr_context=token
+ if must_reparse==False or not len(fragment) :
+ aux.append(token)
+ continue
+ pos=99999999
+ token_list_winner=None
+ for allow, parser in parsers_first :
+ if not allow : continue
+ retval,token_list=parser.parse(fragment, curr_context)
+ if retval :
+ return retval, None
+ must_reparse2,fragment2,dummy=token_list[0]
+ if must_reparse2 :
+ l=len(fragment2)
+ if l<pos :
+ pos=l
+ token_list_winner=token_list
+ else :
+ pos=0
+ token_list_winner=token_list
+ break
+ print token_list_winner
+ if token_list_winner==None : # All parsers are disable
+ aux=[token]+tokens
+ break
+ token=token_list_winner.pop(0)
+ aux.append(token)
+ tokens=token_list_winner+tokens
+ tokens=aux
+
+
+ for allow, parser in parsers_last:
if allow:
aux = []
for token in tokens:
@@ -37,6 +73,7 @@
aux+=token_list
tokens = aux
+ print tokens
return False, "".join([text for dummy, text, dummy in tokens])
import unittest
Modified: trunk/frontend-web/skins/default/body_new_user.html
==============================================================================
--- trunk/frontend-web/skins/default/body_new_user.html (original)
+++ trunk/frontend-web/skins/default/body_new_user.html Thu Jul 12 18:15:47 2007
@@ -3,6 +3,7 @@
<tr><td>Usuario:</td><td><input type="text" name="usuario" size="25" value="" /></td></tr>
<tr><td>Clave:</td><td><input type="password" name="clave1" size="25" value="" /></td></tr>
<tr><td>Confirma la clave:</td><td><input type="password" name="clave2" size="25" value="" /></td></tr>
+ <tr><td>Correo electrónico:</td><td><input type="text" name="email" size="35" value="" /></td></tr>
<tr><td>Servidores OpenID:</td><td><input type="text" name="OpenID1" size=55 value="" /></td></tr>
<tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID2" size=55 value="" /></td></tr>
<tr><td> </td><td><input type="text" name="OpenID3" size=55 value="" /></td></tr>
Modified: trunk/frontend-web/skins/default/body_show_thread.html
==============================================================================
--- trunk/frontend-web/skins/default/body_show_thread.html (original)
+++ trunk/frontend-web/skins/default/body_show_thread.html Thu Jul 12 18:15:47 2007
@@ -68,34 +68,31 @@
post.appendChild(document.getElementById("form"));
toggleBox('form',1);
-/* if(id == "hilos") { return; } */
+ if(id == "hilos") { return; }
/* quotes */
-/* var my_id = id.slice(1); */
-/* if(! used_ids[my_id]){ */
-/* used_ids[my_id] = true; */
-/* var req = false; */
-/* try { */
-/* req = new XMLHttpRequest(); */
-/* } */
-/* catch(e) { */
-/* req = false; */
-/* } */
-/* if(req) { */
-/* req.open("GET","/get_msg_source/"+my_id,false); */
-/* req.send(""); */
-/* var xml = req.responseXML;; */
-/* var author = xml.getElementsByTagName("autor")[0].textContent; */
-/* var post = xml.getElementsByTagName("cuerpo")[0].textContent; */
-/* post = post.replace("<","<"); */
-/* post = post.replace(">",">"); */
-/* post = post.replace("&","&"); */
-/* var form = document.getElementById("form"); */
-/* var textarea = form.getElementsByTagName("textarea")[0]; */
-/* text = '[quote="'+author+'"]'+post+'[/quote]\n'; */
-/* textarea.value += text; */
-/* } */
-/* } */
+ var my_id = id.slice(1);
+ if(! used_ids[my_id]){
+ used_ids[my_id] = true;
+ var req = false;
+ try {
+ req = new XMLHttpRequest();
+ }
+ catch(e) {
+ req = false;
+ }
+ if(req) {
+ req.open("GET","/get_msg_source/"+my_id,false);
+ req.send("");
+ var xml = req.responseXML;;
+ var author = xml.getElementsByTagName("autor")[0].textContent;
+ var post = xml.getElementsByTagName("cuerpo")[0].textContent;
+ var form = document.getElementById("form");
+ var textarea = form.getElementsByTagName("textarea")[0];
+ text = '[quote="'+author+'"]'+post+'[/quote]\n';
+ textarea.value += text;
+ }
+ }
}
window.onload = toggleBox('form',0);
Modified: trunk/frontend-web/url_nuevo_usuario_POST.py
==============================================================================
--- trunk/frontend-web/url_nuevo_usuario_POST.py (original)
+++ trunk/frontend-web/url_nuevo_usuario_POST.py Thu Jul 12 18:15:47 2007
@@ -25,14 +25,20 @@
nick=cuerpo.getfirst("usuario")
clave1=cuerpo.getfirst("clave1")
clave2=cuerpo.getfirst("clave2")
- if not (nick and clave1 and clave2) : # Comprobamos el caso de campos inexistentes
+ email=cuerpo.getfirst("email")
+ try :
+ nick=nick.strip()
+ clave1=clave1.strip()
+ clave2=clave2.strip()
+ email=email.strip()
+ except :
+ nick="" # Generate an error
+
+ if not (nick and clave1 and clave2 and email) : # Comprobamos el caso de campos inexistentes
pagina.load_url(["error"])
pagina.load_dict({"generic_message": "<h1>No puedes dejar ningun campo no opcional en blanco</h1>"})
return pagina.web()
- nick=nick.strip()
- clave1=clave1.strip()
- clave2=clave2.strip()
OpenIDs=set()
for i in xrange(1,6) :
OpenID=cuerpo.getfirst("OpenID%d" %i)
@@ -45,28 +51,31 @@
return pagina.web()
OpenIDs.add(OpenID)
- if not (nick and clave1 and clave2) :
- pagina.load_url(["error"])
- pagina.load_dict({"generic_message": "<h1>No puedes dejar ningun campo no opcional en blanco</h1>"})
- return pagina.web()
-
- if '"' in nick :
- pagina.load_url(["error"])
- pagina.load_dict({"generic_message": "<h1>Caracteres extraños en el nombre de usuario</h1>"})
- return pagina.web()
+ for i in ['"',"'",'<','>','&'] :
+ if i in nick :
+ pagina.load_url(["error"])
+ pagina.load_dict({"generic_message": "<h1>Caracteres extraños en el nombre de usuario</h1>"})
+ return pagina.web()
if clave1!=clave2 :
pagina.load_url(["error"])
pagina.load_dict({"generic_message": "<h1>Las claves introducidas no coinciden</h1>"})
return (pagina.web())
+ for i in ['"',"'",'<','>','&',' ','\t'] : # Deberiamos poner realmente una lista de los permitidos
+ if i in email:
+ error="<h1>Caracteres extraños en la direccion</h1>"
+ pagina.load_url(["error"])
+ pagina.load_dict({"generic_message": "<h1>Caracteres extraños en la dirección de correo</h1>"})
+ return pagina.web()
+
import database
if database.usuario_verifica(conn,nick=nick) :
pagina.load_url(["error"])
pagina.load_dict({"generic_message": "<h1>El usuario ya existe</h1>"})
return (pagina.web())
- database.usuario_add(conn,nick,None,clave=clave1,OpenIDs=OpenIDs)
+ database.usuario_add(conn,nick,None,clave=clave1,email=email,OpenIDs=OpenIDs)
pagina.load_dict({"generic_message": "<h1>Alta exitosa</h1>"})
return (pagina.web())
Modified: trunk/frontend-web/url_perfil.py
==============================================================================
--- trunk/frontend-web/url_perfil.py (original)
+++ trunk/frontend-web/url_perfil.py Thu Jul 12 18:15:47 2007
@@ -29,6 +29,7 @@
texto=["<tr><td>Usuario:</td><td>%s</td></tr>" %usuario_pedido]
texto.append('<tr><td>Clave nueva:</td><td><input type="password" name="clave1" size="25" value="" /></td></tr>')
texto.append('<tr><td>Confirma clave nueva:</td><td><input type="password" name="clave2" size="25" value="" /></td></tr>')
+ texto.append('<tr><td>Correo electrónico:</td><td>%s</td></tr>' %u["email"])
OpenIDs=list(u["OpenID"])+["","","","",""] # Padding
texto.append('<tr><td>Servidores OpenID:</td><td><input type="text" name="OpenID1" size=55 value="%s" /></td></tr>' %OpenIDs[0])
texto.append('<tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID2" size=55 value="%s" /></td></tr>' %OpenIDs[1])
More information about the cpif
mailing list