quixote errors.py,1.21,1.22

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]>
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Update of /home/cvs/quixote
In directory hewson:/tmp/cvs-serv15997

Modified Files:
	errors.py 
Log Message:
Don't return htmltext from format() unless some piece of data is
already htmltext (for backwards compatibility).  Note that:

    a = str(a)
    b = htmltext(b)
    a += b

does not work while:

    a = str(a)
    b = htmltext(b)
    a = a + b
    
IOW, there is no __riadd__ method.


Index: errors.py
===================================================================
RCS file: /home/cvs/quixote/errors.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- errors.py	14 Oct 2002 22:58:12 -0000	1.21
+++ errors.py	16 Oct 2002 16:02:13 -0000	1.22
@@ -2,7 +2,7 @@
 
 Exception classes used by Quixote
 """
-from quixote.html import htmltext
+from quixote.html import htmltext, htmlescape
 
 __revision__ = "$Id$"
 
@@ -42,11 +42,13 @@
         return self.private_msg or self.public_msg or "???"
 
     def format (self, request):
-        msg = self.title
+        msg = htmlescape(self.title)
+        if not isinstance(self.title, htmltext):
+            msg = str(msg) # for backwards compatibility
         if self.public_msg:
-            msg += ": " + self.public_msg
+            msg = msg + ": " + self.public_msg
         if self.private_msg:
-            msg += ": " + self.private_msg
+            msg = msg + ": " + self.private_msg
         return msg
 
 
@@ -75,11 +77,13 @@
         self.path = path
 
     def format (self, request):
-        msg = self.title + ": " + self.path
+        msg = htmlescape(self.title) + ": " + self.path
+        if not isinstance(self.title, htmltext):
+            msg = str(msg) # for backwards compatibility
         if self.public_msg:
-            msg += ": " + self.public_msg
+            msg = msg + ": " + self.public_msg
         if self.private_msg:
-            msg += ": " + self.private_msg
+            msg = msg + ": " + self.private_msg
         return msg
 
 class RequestError (PublishError):
@@ -140,7 +144,7 @@
         get_session_manager().revoke_session_cookie(request)
         msg = PublishError.format(self, request)
         if self.session_id:
-            msg += ": " + self.session_id
+            msg = msg + ": " + self.session_id
         return msg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.