[cpif] r308 - in trunk: backend frontend-web
svn at argo.es
svn at argo.es
Mon Jul 30 19:19:15 CEST 2007
Author: jcea
Date: Mon Jul 30 19:19:14 2007
New Revision: 308
Log:
Más infraestructura para la monitorizacion
Modified:
trunk/backend/database.py
trunk/frontend-web/url_toggle_monitor_AJAX.py
Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py (original)
+++ trunk/backend/database.py Mon Jul 30 19:19:14 2007
@@ -557,3 +557,43 @@
def monitored_metatag(conn,usuario,metatag) :
return metatag in conn.get_root()["usuarios"]["usuarios"][normaliza_nick(usuario)]["monitor metatags"]
+def toggle_monitor_metatag(conn,usuario,metatag) :
+ root=conn.get_root()
+ nick_norm=normaliza_nick(usuario)
+ u=root["usuarios"]["usuarios"][nick_norm]
+
+ if metatag in u["monitor metatags"] :
+ del u["monitor metatags"][metatag]
+ del root["metatags"]["metatags"][metatag]["monitor"][nick_norm]
+ return None,False
+
+ if metatag not in u["punto de lectura no leidos"] : # Check permission
+ return "Too clever for your own good...",False
+
+ root["metatags"]["metatags"][metatag]["monitor"][nick_norm]=None
+ u["monitor metatags"][metatag]=None
+ return None,True
+
+def toggle_monitor_thread(conn,usuario,thread) :
+ root=conn.get_root()
+ nick_norm=normaliza_nick(usuario)
+ u=root["usuarios"]["usuarios"][nick_norm]
+
+ if thread in u["monitor hilos"] :
+ del u["monitor hilos"][thread]
+ del root["hilos"]["hilos"][thread]["monitor"][nick_norm]
+ return None,False
+
+ thr=root["hilos"]["hilos"].get(thread)
+ if not thr : return "ERROR",False
+ plnl=u["punto de lectura no leidos"]
+ for i in thr["metatags"] :
+ if i in plnl : # Check permission
+ break
+ else :
+ return "Too clever for your own good...",False
+
+ thr["monitor"][usuario]=None
+ u["monitor hilos"][thread]=None
+ return None,True
+
Modified: trunk/frontend-web/url_toggle_monitor_AJAX.py
==============================================================================
--- trunk/frontend-web/url_toggle_monitor_AJAX.py (original)
+++ trunk/frontend-web/url_toggle_monitor_AJAX.py Mon Jul 30 19:19:14 2007
@@ -9,15 +9,27 @@
tipo=path[1]
if (tipo!="thread") and (tipo!="metatag") :
return None
- num_thread=int(path[2])
+ num=int(path[2])
except :
return None
+ from database import toggle_monitor_metatag,toggle_monitor_thread
+ func=toggle_monitor_metatag if (tipo=="metatag") else toggle_monitor_thread
+ error,status=func(conn,usuario,num)
+ print "XX",error,status
+ if error :
+ msg=error
+ else :
+ if status :
+ msg="Dejar de monitorizar"
+ else :
+ msg="Monitorizar"
+
from xml.sax.saxutils import escape
return (200,{"Content-Type":"text/xml; charset=utf-8"},
"""<?xml version="1.0" ?>
<root>
<msg>%s</msg>
</root>
-""" %(escape("Nothing to see yet. Move along...")))
+""" %(escape(msg)))
More information about the cpif
mailing list