--- comments.py	Fri Sep 26 06:57:31 2003
+++ comments.py~	Tue Oct 28 19:40:15 2003
@@ -28,6 +28,10 @@
     filelist.sort()
     if not entry.has_key('num_comments'):
         entry['num_comments'] = len(filelist)
+        if (len(filelist)!=1):
+            entry['say_comments'] = "%d comments" % (len(filelist))
+        else:
+            entry['say_comments'] = "1 comment"
     return [ readComment(f) for f in filelist ]
     
 def getCommentCount(entry, config):
@@ -126,9 +130,9 @@
         cfile = open(cfn, "w")
     
         def makeXMLField(name, field):
-            return "<"+name+">"+cgi.escape(field[name])+"</"+name+">\n";
+            return "<"+name+">"+cgi.escape(field[name].encode(config.get('blog_encoding','iso-8859-1')))+"</"+name+">\n";
     
-        cfile.write('<?xml version="1.0" encoding="iso-8859-1"?>\n')
+        cfile.write('<?xml version="1.0" encoding="%s"?>\n' % (config.get('blog_encoding','iso-8859-1')))
         cfile.write("<item>\n")
         cfile.write(makeXMLField('title',comment))
         cfile.write(makeXMLField('author',comment))
@@ -167,7 +171,7 @@
         except:
             pass
 
-def sanitize(body):
+def sanitize(body,config):
     """
     This code shamelessly lifted from Sam Ruby's mombo/post.py
     """
@@ -258,17 +262,17 @@
     
     if form.has_key("title") and form.has_key("author") and form.has_key("body"):
 
-        body = form['body'].value
+        body = form['body'].value.decode(config.get('blog_encoding','iso-8859-1'))
         
-        body = sanitize(body)
+        body = sanitize(body,config)
 
         # Check if the form has a URL
         url = (form.has_key('url') and [form['url'].value] or [''])[0]
         
-        cdict = {'title': form['title'].value, \
-                 'author' : form['author'].value, \
+        cdict = {'title': form['title'].value.decode(config.get('blog_encoding','iso-8859-1')), \
+                 'author' : form['author'].value.decode(config.get('blog_encoding','iso-8859-1')), \
                  'pubDate' : str(time.time()), \
-                 'link' : url, \
+                 'link' : url.decode(config.get('blog_encoding','iso-8859-1')), \
                  'source' : '', \
                  'description' : body }
         
@@ -301,8 +305,14 @@
     config = request.getConfiguration()
     if len(renderer.getContent()) == 1 and renderer.flavour.has_key('comment-story'):
         template = renderer.flavour.get('comment-story','')
+        args['template'] = template
     else:
-        entry['num_comments'] = getCommentCount(entry,config)
+        numero = getCommentCount(entry,config)
+        entry['num_comments'] = numero
+        if (numero != 1):
+            entry['say_comments'] = "%d comments" % (numero)
+        else:
+            entry['say_comments'] = "1 comment"
         return template
 
 def cb_story_end(args):
@@ -321,6 +331,10 @@
         args['template'] = template +u"".join(output)
     else:
         entry['num_comments'] = getCommentCount(entry,config)
+        if (entry['num_comments']!=1):
+            entry['say_comments'] = "%d comments" % (entry['num_comments'])
+        else:
+            entry['say_comments'] = "1 comment"
         return template
     
 def cb_start(args):
@@ -337,3 +351,4 @@
         config['comment_dir'] = os.path.join(config['datadir'],'comments')
     if not config.has_key('comment_ext'):
         config['comment_ext'] = 'cmt'
+
