[cpif] r255 - in trunk: backend frontend-web
svn at argo.es
svn at argo.es
Tue Jul 10 13:29:15 CEST 2007
Author: jcea
Date: Tue Jul 10 13:29:15 2007
New Revision: 255
Log:
Primeros pasos para 'quotear' mensajes
Added:
trunk/frontend-web/url_get_msg_source.py
- copied, changed from r252, /trunk/frontend-web/url_static.py
Modified:
trunk/backend/database.py
Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py (original)
+++ trunk/backend/database.py Tue Jul 10 13:29:15 2007
@@ -277,7 +277,13 @@
usuario["punto de lectura no leidos"][num_mt]=BTree()
return num_mt
-
+
+def get_message_source(conn,num_msg) :
+ root=conn.get_root()
+ msg=root["mensajes"]["mensajes"].get(num_msg)
+ if not msg : return None,None
+ return (msg["autor"],msg["texto"][0])
+
def mensaje_add(conn,texto_bruto,texto_procesado,nick,hilo=None,titulo=None,metatag=None) :
from durus.btree import BTree
from durus.persistent_dict import PersistentDict
Copied: trunk/frontend-web/url_get_msg_source.py (from r252, /trunk/frontend-web/url_static.py)
==============================================================================
--- /trunk/frontend-web/url_static.py (original)
+++ trunk/frontend-web/url_get_msg_source.py Tue Jul 10 13:29:15 2007
@@ -4,21 +4,22 @@
@monitor
def gestiona_url(conn,handler,path,usuario) :
- if len(path)!=3 : return None
- section,etag=path[1],path[2]
- headers={"ETag":etag,"Cache-Control":"max-age=31536000"}
+ if len(path)!=2 : return None
+ try :
+ num_msg=int(path[1])
+ except :
+ return None
import database
- data=database.get_static(conn,section,etag)
- if not data : return None # Not found
+ autor,source=database.get_message_source(conn,num_msg)
+ if not source : return None # Not found
- metadata,data=data
- data=data[0] # de-encapsulate
-
- if handler.headers.get("if-none-match")==etag :
- return (304,headers,"")
-
- headers["Content-Type"]=metadata["content-type"]
-
- return (200,headers,data)
+ from xml.sax.saxutils import escape
+ return (200,{"Content-Type":"text/xml; charset=utf-8"},
+"""<?xml version="1.0" ?>
+<root>
+<autor>%s</autor>
+<cuerpo>%s</cuerpo>
+</root>
+""" %(escape(autor),escape(source)))
More information about the cpif
mailing list