[cpif] r316 - in trunk: backend frontend-web
svn at argo.es
svn at argo.es
Mon Jul 30 21:22:41 CEST 2007
Author: jcea
Date: Mon Jul 30 21:22:41 2007
New Revision: 316
Log:
Monitorizacion de hilos y metatags
Modified:
trunk/backend/database.py
trunk/backend/upgrade.py
trunk/frontend-web/url_edit_config.py
trunk/frontend-web/url_perfil_POST.py
Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py (original)
+++ trunk/backend/database.py Mon Jul 30 21:22:41 2007
@@ -1,7 +1,7 @@
# $Id$
-VERSION_DB="2007072701"
+VERSION_DB="2007073001"
import globales
@@ -77,6 +77,7 @@
conf["allow_bbcode"]=True
conf["allow_html"]=True
conf["allow_avatar_change"]=False # Because You could not have the libs!
+ conf["base_url"]=""
conf["smtp_server"]=""
conf["smtp_server_port"]=25
conf["smtp_auth_user"]=""
@@ -384,6 +385,7 @@
h=hilo
mensaje["hilo"]=hilo
hilo=hilos["hilos"][hilo]
+ mon=hilo["monitor"]
last=hilo["mensajes"].get_max_item()[0]
del seguimiento_no_leidos["last_msg2hilo"][last]
TS=hilo["TS"]
@@ -394,6 +396,7 @@
hilos["num_hilos"]+=1
h=hilos["num_hilos"]
root["punto_de_lectura_global"][h]=0
+ mon=root["metatags"]["metatags"][metatag]["monitor"]
hilo=PersistentDict()
assert titulo
hilo=PersistentDict(
@@ -407,6 +410,7 @@
"numeros":BTree()})
hilos["hilos"][h]=hilo
mensaje["hilo"]=h
+ last=0 # Simplify mailing
seguimiento_no_leidos["hilo2last_msg"][h]=num_msg
seguimiento_no_leidos["last_msg2hilo"][num_msg]=h
@@ -422,6 +426,37 @@
usuario=root["usuarios"]["usuarios"][usuario]
usuario["num mensajes"]+=1
usuario["mensajes"][num_msg]=mensaje
+
+ meta_u=root["usuarios"]["usuarios"]
+ destinations=[]
+ for i in mon.iterkeys() :
+ u=meta_u[i]
+ umc=u["ultimo mensaje conocido"]
+ if umc<last : continue # Already notified
+ if h in u["punto de lectura no leidos"][list(hilo["metatags"])[0]] :
+ continue # Already notified
+ email=u["email"]
+ if email : destinations.append(email)
+ if len(destinations) :
+ from email.header import Header
+ import smtp
+ texto=["From: %s" %globales.smtp_email_sender]
+ texto.append("To: %s" %globales.smtp_email_sender)
+
+ if last : # Thread
+ texto.append("Subject: Nuevo mensaje en el hilo %s"
+ %Header("'%s'" %hilo["titulo"],"utf-8",76,"Subject: Nuevo mensaje en el hilo ").encode())
+ texto.append("")
+ texto.append("Nuevo mensaje")
+ texto.append("%s/hilo/%d/%d#m%d" %(globales.base_url,h,1+globales.thread_len*((num_mensajes-1)/globales.thread_len),num_msg))
+ else : # Metatag
+ texto.append("Subject: Nuevo hilo %s"
+ %Header("'%s'" %hilo["titulo"],"utf-8",76,"Subject: Nuevo hilo ").encode())
+ texto.append("")
+ texto.append("Nuevo hilo")
+ texto.append("%s/hilo/%d" %(globales.base_url,h))
+
+ smtp.enqueue(conn,destinations,"\r\n".join(texto))
def actualiza_no_leidos(conn,usuario) :
root=conn.get_root()
Modified: trunk/backend/upgrade.py
==============================================================================
--- trunk/backend/upgrade.py (original)
+++ trunk/backend/upgrade.py Mon Jul 30 21:22:41 2007
@@ -266,3 +266,9 @@
hilo["monitor"]=BTree()
conn.commit()
+ if root["version del foro"]=="2007072701" :
+ print "Actualizando la base de datos: 2007072701 -> 2007073001"
+ root["version del foro"]="2007073001"
+ root["config"]["base_url"]=""
+ conn.commit()
+
Modified: trunk/frontend-web/url_edit_config.py
==============================================================================
--- trunk/frontend-web/url_edit_config.py (original)
+++ trunk/frontend-web/url_edit_config.py Mon Jul 30 21:22:41 2007
@@ -24,6 +24,7 @@
texto.append('<tr><td>Allow BBcode?</td><td><input type="checkbox" name="allow_bbcode" %s /></td></tr>' % ("CHECKED" if globales.allow_bbcode else ""))
texto.append('<tr><td>Allow HTML?</td><td><input type="checkbox" name="allow_html" %s /></td></tr>' % ("CHECKED" if globales.allow_html else ""))
texto.append('<tr><td>Allow avatar change<br/>(Requires library. See docs)</td><td><input type="checkbox" name="allow_avatar_change" %s /></td></tr>' % ("CHECKED" if globales.allow_avatar_change else ""))
+ texto.append('<tr><td>Base URL for this service<br/>(<b>DO NOT</b> write down the last slash)</td><td><input type="text" name="base_url" size="50" value="%s" /></td><tr>' %globales.base_url)
texto.append('<tr><td>Outgoing SMTP server</td><td><input type="text" name="smtp_server" size="30" value="%s" /></td><tr>' %globales.smtp_server)
texto.append('<tr><td>Outgoing SMTP server port</td><td><input type="text" name="smtp_server_port" size="5" value="%d" /></td></tr>' %globales.smtp_server_port)
texto.append('<tr><td>SMTP sender address</td><td><input type="text" name="smtp_email_sender" size="30" value="%s" /></td><tr>' %globales.smtp_email_sender)
Modified: trunk/frontend-web/url_perfil_POST.py
==============================================================================
--- trunk/frontend-web/url_perfil_POST.py (original)
+++ trunk/frontend-web/url_perfil_POST.py Mon Jul 30 21:22:41 2007
@@ -64,13 +64,7 @@
new_email=new_email.strip()
if new_email :
- host=handler.headers.getheader("host")
- if not host :
- pagina.load_url(["error"])
- pagina.load_dict({"generic_message": "<h1>La cabecera 'host' no existe</h1>"})
- return (pagina.web())
-
- from globales import smtp_email_sender
+ from globales import smtp_email_sender,base_url
nonce=database.usuario_ask_new_email(conn,usuario_pedido,new_email)
texto=["From: %s" %smtp_email_sender]
texto.append("To: %s" %new_email)
@@ -79,7 +73,7 @@
texto.append("Autentifiquese en el foro y, despues, pulse sobre el")
texto.append("siguiente enlace:")
texto.append("")
- texto.append("http://%s/email_confirmation/%s" %(host,nonce))
+ texto.append("%s/email_confirmation/%s" %(base_url,nonce))
import smtp
smtp.enqueue(conn,[new_email],"\r\n".join(texto))
More information about the cpif
mailing list