4 # blitiri - A single-file blog engine.
5 # Alberto Bertogli (albertito@gmail.com)
8 # Configuration section
10 # You can edit these values, or create a file named "config.py" and put them
11 # there to make updating easier. The ones in config.py take precedence.
14 # Directory where entries are stored
15 data_path = "/tmp/blog/data"
17 # Are comments allowed? (if False, comments_path option is not used)
18 enable_comments = False
20 # Directory where comments are stored (must be writeable by the web server)
21 comments_path = "/tmp/blog/comments"
23 # Path where templates are stored. Use an empty string for the built-in
24 # default templates. If they're not found, the built-in ones will be used.
25 templates_path = "/tmp/blog/templates"
27 # URL to the blog, including the name. Can be a full URL or just the path.
28 blog_url = "/blog/blitiri.cgi"
30 # Style sheet (CSS) URL. Can be relative or absolute. To use the built-in
31 # default, set it to blog_url + "/style".
32 css_url = blog_url + "/style"
35 title = "I don't like blogs"
38 author = "Hartmut Kegan"
44 class Captcha (object):
45 def __init__(self, article):
46 self.article = article
47 words = article.title.split()
48 self.nword = hash(article.title) % len(words) % 5
49 self.answer = words[self.nword]
50 self.help = 'gotcha, damn spam bot!'
53 nword = self.nword + 1
62 return "enter the %s word of the article's title" % n
63 puzzle = property(fget = get_puzzle)
65 def validate(self, form_data):
66 if form_data.captcha.lower() == self.answer.lower():
72 # End of configuration
73 # DO *NOT* EDIT ANYTHING PAST HERE
87 from docutils.core import publish_parts
88 from docutils.utils import SystemMessage
90 # Before importing the config, add our cwd to the Python path
91 sys.path.append(os.getcwd())
93 # Load the config file, if there is one
100 # Pimp *_path config variables to support relative paths
101 data_path = os.path.realpath(data_path)
102 templates_path = os.path.realpath(templates_path)
106 default_main_header = """\
107 <?xml version="1.0" encoding="utf-8"?>
108 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
109 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
111 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
113 <link rel="alternate" title="%(title)s" href="%(fullurl)s/atom"
114 type="application/atom+xml" />
115 <link href="%(css_url)s" rel="stylesheet" type="text/css" />
116 <title>%(title)s</title>
121 <h1><a href="%(url)s">%(title)s</a></h1>
123 <div class="content">
126 default_main_footer = """
129 %(showyear)s: %(monthlinks)s<br/>
130 years: %(yearlinks)s<br/>
131 subscribe: <a href="%(url)s/atom">atom</a><br/>
132 views: <a href="%(url)s/">blog</a> <a href="%(url)s/list">list</a><br/>
139 default_article_header = """
140 <div class="article">
141 <h2><a href="%(url)s/post/%(uuid)s">%(arttitle)s</a></h2>
142 <span class="artinfo">
143 by %(author)s on <span class="date">
145 <a class="date" href="%(url)s/%(cyear)d/">%(cyear)04d</a>-\
146 <a class="date" href="%(url)s/%(cyear)d/%(cmonth)d/">%(cmonth)02d</a>-\
147 <a class="date" href="%(url)s/%(cyear)d/%(cmonth)d/%(cday)d/">%(cday)02d</a>\
148 %(chour)02d:%(cminute)02d</span>
149 (updated on <span class="date">
150 <a class="date" href="%(url)s/%(uyear)d/">%(uyear)04d</a>-\
151 <a class="date" href="%(url)s/%(uyear)d/%(umonth)d/">%(umonth)02d</a>-\
152 <a class="date" href="%(url)s/%(uyear)d/%(umonth)d/%(uday)d/">%(uday)02d</a>\
153 %(uhour)02d:%(uminute)02d)</span><br/>
154 <span class="tags">tagged %(tags)s</span> -
155 <span class="comments">with %(comments)s
156 <a href="%(url)s/post/%(uuid)s#comments">comment(s)</a></span>
159 <div class="artbody">
162 default_article_footer = """
168 default_comment_header = """
169 <div class="comment">
170 <a name="comment-%(number)d" />
171 <h3><a href="#comment-%(number)d">Comment #%(number)d</a></h3>
172 <span class="cominfo">by %(linked_author)s
173 on %(year)04d-%(month)02d-%(day)02d %(hour)02d:%(minute)02d</span>
175 <div class="combody">
178 default_comment_footer = """
184 default_comment_form = """
185 <div class="comform">
187 <h3 class="comform"><a href="#comment">Your comment</a></h3>
188 <div class="comforminner">
189 <form method="%(form_method)s" action="%(form_action)s">
190 <div class="comformauthor">
191 <label for="comformauthor">Your name %(form_author_error)s</label>
192 <input type="text" class="comformauthor" id="comformauthor"
193 name="comformauthor" value="%(form_author)s" />
195 <div class="comformlink">
196 <label for="comformlink">Your link
197 <span class="comformoptional">(optional, will be published)</span>
198 %(form_link_error)s</label>
199 <input type="text" class="comformlink" id="comformlink"
200 name="comformlink" value="%(form_link)s" />
201 <div class="comformhelp">
202 like <span class="formurlexample">http://www.example.com/</span>
203 or <span class="formurlexample">mailto:you@example.com</span>
206 <div class="comformcaptcha">
207 <label for="comformcaptcha">Your humanity proof %(form_captcha_error)s</label>
208 <input type="text" class="comformcaptcha" id="comformcaptcha"
209 name="comformcaptcha" value="%(form_captcha)s" />
210 <div class="comformhelp">%(captcha_puzzle)s</div>
212 <div class="comformbody">
213 <label for="comformbody" class="comformbody">The comment
214 %(form_body_error)s</label>
215 <textarea class="comformbody" id="comformbody" name="comformbody" rows="15"
216 cols="80">%(form_body)s</textarea>
217 <div class="comformhelp">
219 <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">\
220 RestructuredText</a> format, please
223 <div class="comformsend">
224 <button type="submit" class="comformsend" id="comformsend" name="comformsend">
233 default_comment_error = '<span class="comformerror">(%(error)s)</span>'
239 font-family: sans-serif;
250 border-bottom: 2px solid #99F;
259 border-bottom: 1px solid #99C;
266 border-bottom: 1px solid #99C;
270 text-decoration: none;
279 text-decoration: none;
283 span.artinfo a:hover {
284 text-decoration: none;
301 text-decoration: none;
305 span.cominfo a:hover {
306 text-decoration: none;
330 border-bottom: 1px solid #99C;
335 div.comform span.comformoptional {
351 span.formurlexample {
353 background-color: #EEF;
354 font-family: monospace;
356 padding-right: 0.2em;
359 textarea.comformbody {
360 font-family: monospace;
380 background-color: #99F;
388 border-top: 2px solid #99F;
393 text-decoration: none;
396 /* Articles are enclosed in <div class="section"> */
402 border-bottom: 1px dotted #99C;
408 def rst_to_html(rst):
410 'input_encoding': encoding,
411 'output_encoding': 'utf8',
415 parts = publish_parts(rst, settings_overrides = settings,
416 writer_name = "html")
417 return parts['body'].encode('utf8')
419 def validate_rst(rst):
423 except SystemMessage, e:
424 desc = e.args[0].encode('utf-8') # the error string
425 desc = desc[9:] # remove "<string>:"
426 line = int(desc[:desc.find(':')]) # get just the line number
427 desc = desc[desc.find(')')+2:-1] # remove (LEVEL/N)
429 desc, context = desc.split('\n', 1)
432 if desc.endswith('.'):
434 return (line, desc, context)
436 def valid_link(link):
438 mail_re = r"^[^ \t\n\r@<>()]+@[a-z0-9][a-z0-9\.\-_]*\.[a-z]+$"
439 scheme_re = r'^[a-zA-Z]+:'
440 url_re = r'^(?:[a-z0-9\-]+|[a-z0-9][a-z0-9\-\.\_]*\.[a-z]+)' \
441 r'(?::[0-9]+)?(?:/.*)?$'
444 if re.match(scheme_re, link, re.I):
445 scheme, rest = link.split(':', 1)
446 if (not scheme or scheme == 'mailto') and re.match(mail_re, rest, re.I):
447 return 'mailto:' + link
448 if not scheme and re.match(url_re, rest, re.I):
449 return 'http://' + rest
455 if isinstance(obj, basestring):
456 return cgi.escape(obj, True)
460 # find out our URL, needed for syndication
462 n = os.environ['SERVER_NAME']
463 p = os.environ['SERVER_PORT']
464 s = os.environ['SCRIPT_NAME']
467 full_url = 'http://%s%s%s' % (n, p, s)
469 full_url = 'Not needed'
472 class Templates (object):
473 def __init__(self, tpath, db, showyear = None):
476 now = datetime.datetime.now()
488 'showyear': showyear,
489 'monthlinks': ' '.join(db.get_month_links(showyear)),
490 'yearlinks': ' '.join(db.get_year_links()),
493 def get_template(self, page_name, default_template, extra_vars = None):
494 if extra_vars is None:
497 vars = self.vars.copy()
498 vars.update(extra_vars)
500 p = '%s/%s.html' % (self.tpath, page_name)
501 if os.path.isfile(p):
502 return open(p).read() % vars
503 return default_template % vars
505 def get_main_header(self):
506 return self.get_template('header', default_main_header)
508 def get_main_footer(self):
509 return self.get_template('footer', default_main_footer)
511 def get_article_header(self, article):
512 return self.get_template(
513 'art_header', default_article_header, article.to_vars())
515 def get_article_footer(self, article):
516 return self.get_template(
517 'art_footer', default_article_footer, article.to_vars())
519 def get_comment_header(self, comment):
520 vars = comment.to_vars()
522 vars['linked_author'] = '<a href="%s">%s</a>' \
523 % (comment.link, comment.author)
525 vars['linked_author'] = comment.author
526 return self.get_template(
527 'com_header', default_comment_header, vars)
529 def get_comment_footer(self, comment):
530 return self.get_template(
531 'com_footer', default_comment_footer, comment.to_vars())
533 def get_comment_form(self, article, form_data, captcha_puzzle):
534 vars = article.to_vars()
535 vars.update(form_data.to_vars(self))
536 vars['captcha_puzzle'] = captcha_puzzle
537 return self.get_template(
538 'com_form', default_comment_form, vars)
540 def get_comment_error(self, error):
541 return self.get_template(
542 'com_error', default_comment_error, dict(error=error))
545 class CommentFormData (object):
546 def __init__(self, author = '', link = '', captcha = '', body = ''):
549 self.captcha = captcha
551 self.author_error = ''
553 self.captcha_error = ''
558 def to_vars(self, template):
559 render_error = template.get_comment_error
560 a_error = self.author_error and render_error(self.author_error)
561 l_error = self.link_error and render_error(self.link_error)
562 c_error = self.captcha_error \
563 and render_error(self.captcha_error)
564 b_error = self.body_error and render_error(self.body_error)
566 'form_author': sanitize(self.author),
567 'form_link': sanitize(self.link),
568 'form_captcha': sanitize(self.captcha),
569 'form_body': sanitize(self.body),
571 'form_author_error': a_error,
572 'form_link_error': l_error,
573 'form_captcha_error': c_error,
574 'form_body_error': b_error,
576 'form_action': self.action,
577 'form_method': self.method,
581 class Comment (object):
582 def __init__(self, article, number, created = None):
583 self.article = article
586 self.created = datetime.datetime.now()
588 self.created = created
593 self._author = author
595 self._raw_content = 'Removed comment'
598 def get_author(self):
602 author = property(fget = get_author)
608 link = property(fget = get_link)
610 def get_raw_content(self):
613 return self._raw_content
614 raw_content = property(fget = get_raw_content)
617 def set(self, author, raw_content, link = '', created = None):
619 self._author = author
620 self._raw_content = raw_content
622 self.created = created or datetime.datetime.now()
626 filename = os.path.join(comments_path, self.article.uuid,
629 raw = open(filename).readlines()
636 name, value = l.split(':', 1)
637 if name.lower() == 'author':
638 self._author = value.strip()
639 elif name.lower() == 'link':
640 self._link = value.strip()
645 self._raw_content = ''.join(raw[count + 1:])
649 filename = os.path.join(comments_path, self.article.uuid,
652 f = open(filename, 'w')
653 f.write('Author: %s\n' % self.author)
654 f.write('Link: %s\n' % self.link)
656 f.write(self.raw_content)
662 return rst_to_html(self.raw_content)
666 'number': self.number,
667 'author': sanitize(self.author),
668 'link': sanitize(self.link),
669 'date': self.created.isoformat(' '),
670 'created': self.created.isoformat(' '),
672 'year': self.created.year,
673 'month': self.created.month,
674 'day': self.created.day,
675 'hour': self.created.hour,
676 'minute': self.created.minute,
677 'second': self.created.second,
680 class CommentDB (object):
681 def __init__(self, article):
682 self.path = os.path.join(comments_path, article.uuid)
686 def load(self, article):
688 f = open(os.path.join(self.path, 'db'))
693 # Each line has the following comma separated format:
694 # number, created (epoch)
695 # Empty lines are meaningful and represent removed
696 # comments (so we can preserve the comment number)
700 d = datetime.datetime.fromtimestamp(float(l[1]))
702 # Removed/invalid comment
703 self.comments.append(None)
705 self.comments.append(Comment(article, n, d))
708 old_db = os.path.join(self.path, 'db')
709 new_db = os.path.join(self.path, 'db.tmp')
710 f = open(new_db, 'w')
711 for c in self.comments:
715 s += str(c.number) + ', '
716 s += str(time.mktime(c.created.timetuple()))
720 os.rename(new_db, old_db)
723 class Article (object):
724 def __init__(self, path, created = None, updated = None):
726 self.created = created
727 self.updated = updated
728 self.uuid = "%08x" % zlib.crc32(self.path)
733 self._title = 'Removed post'
734 self._author = author
736 self._raw_content = ''
744 title = property(fget = get_title)
746 def get_author(self):
750 author = property(fget = get_author)
756 tags = property(fget = get_tags)
758 def get_raw_content(self):
761 return self._raw_content
762 raw_content = property(fget = get_raw_content)
764 def get_comments(self):
767 return self._comments
768 comments = property(fget = get_comments)
771 def __cmp__(self, other):
772 if self.path == other.path:
776 if not other.created:
778 if self.created < other.created:
782 def title_cmp(self, other):
783 return cmp(self.title, other.title)
786 def add_comment(self, author, raw_content, link = ''):
787 c = Comment(self, len(self.comments))
788 c.set(author, raw_content, link)
789 self.comments.append(c)
794 # XXX this tweak is only needed for old DB format, where
795 # article's paths started with a slash
797 if path.startswith('/'):
799 filename = os.path.join(data_path, path)
801 raw = open(filename).readlines()
808 name, value = l.split(':', 1)
809 if name.lower() == 'title':
810 self._title = value.strip()
811 elif name.lower() == 'author':
812 self._author = value.strip()
813 elif name.lower() == 'tags':
814 ts = value.split(',')
815 ts = [t.strip() for t in ts]
821 self._raw_content = ''.join(raw[count + 1:])
823 self._comments = db.comments
827 return rst_to_html(self.raw_content)
831 'arttitle': sanitize(self.title),
832 'author': sanitize(self.author),
833 'date': self.created.isoformat(' '),
835 'tags': self.get_tags_links(),
836 'comments': len(self.comments),
838 'created': self.created.isoformat(' '),
839 'ciso': self.created.isoformat(),
840 'cyear': self.created.year,
841 'cmonth': self.created.month,
842 'cday': self.created.day,
843 'chour': self.created.hour,
844 'cminute': self.created.minute,
845 'csecond': self.created.second,
847 'updated': self.updated.isoformat(' '),
848 'uiso': self.updated.isoformat(),
849 'uyear': self.updated.year,
850 'umonth': self.updated.month,
851 'uday': self.updated.day,
852 'uhour': self.updated.hour,
853 'uminute': self.updated.minute,
854 'usecond': self.updated.second,
857 def get_tags_links(self):
859 tags = list(self.tags)
862 l.append('<a class="tag" href="%s/tag/%s">%s</a>' % \
863 (blog_url, urllib.quote(t), sanitize(t) ))
867 class ArticleDB (object):
868 def __init__(self, dbpath):
872 self.actyears = set()
873 self.actmonths = set()
876 def get_articles(self, year = 0, month = 0, day = 0, tags = None):
878 for a in self.articles:
879 if year and a.created.year != year: continue
880 if month and a.created.month != month: continue
881 if day and a.created.day != day: continue
882 if tags and not tags.issubset(a.tags): continue
888 def get_article(self, uuid):
889 return self.uuids[uuid]
893 f = open(self.dbpath)
898 # Each line has the following comma separated format:
899 # path (relative to data_path), \
908 datetime.datetime.fromtimestamp(float(l[1])),
909 datetime.datetime.fromtimestamp(float(l[2])))
910 self.uuids[a.uuid] = a
911 self.actyears.add(a.created.year)
912 self.actmonths.add((a.created.year, a.created.month))
913 self.articles.append(a)
916 f = open(self.dbpath + '.tmp', 'w')
917 for a in self.articles:
920 s += str(time.mktime(a.created.timetuple())) + ', '
921 s += str(time.mktime(a.updated.timetuple())) + '\n'
924 os.rename(self.dbpath + '.tmp', self.dbpath)
926 def get_year_links(self):
927 yl = list(self.actyears)
928 yl.sort(reverse = True)
929 return [ '<a href="%s/%d/">%d</a>' % (blog_url, y, y)
932 def get_month_links(self, year):
933 am = [ i[1] for i in self.actmonths if i[0] == year ]
935 for i in range(1, 13):
936 name = calendar.month_name[i][:3]
938 s = '<a href="%s/%d/%d/">%s</a>' % \
939 ( blog_url, year, i, name )
949 def render_comments(article, template, form_data):
950 print '<a name="comments" />'
951 for c in article.comments:
954 print template.get_comment_header(c)
956 print template.get_comment_footer(c)
958 form_data = CommentFormData()
959 form_data.action = blog_url + '/comment/' + article.uuid + '#comment'
960 captcha = Captcha(article)
961 print template.get_comment_form(article, form_data, captcha.puzzle)
963 def render_html(articles, db, actyear = None, show_comments = False,
964 redirect = None, form_data = None):
966 print 'Status: 303 See Other\r\n',
967 print 'Location: %s\r\n' % redirect,
968 print 'Content-type: text/html; charset=utf-8\r\n',
970 template = Templates(templates_path, db, actyear)
971 print template.get_main_header()
973 print template.get_article_header(a)
975 print template.get_article_footer(a)
977 render_comments(a, template, form_data)
978 print template.get_main_footer()
980 def render_artlist(articles, db, actyear = None):
981 template = Templates(templates_path, db, actyear)
982 print 'Content-type: text/html; charset=utf-8\n'
983 print template.get_main_header()
984 print '<h2>Articles</h2>'
986 print '<li><a href="%(url)s/uuid/%(uuid)s">%(title)s</a></li>' \
992 print template.get_main_footer()
994 def render_atom(articles):
995 if len(articles) > 0:
996 updated = articles[0].updated.isoformat()
998 updated = datetime.datetime.now().isoformat()
1000 print 'Content-type: application/atom+xml; charset=utf-8\n'
1001 print """<?xml version="1.0" encoding="utf-8"?>
1003 <feed xmlns="http://www.w3.org/2005/Atom">
1004 <title>%(title)s</title>
1005 <link rel="alternate" type="text/html" href="%(url)s"/>
1006 <link rel="self" type="application/atom+xml" href="%(url)s/atom"/>
1007 <id>%(url)s</id> <!-- TODO: find a better <id>, see RFC 4151 -->
1008 <updated>%(updated)sZ</updated>
1020 'contents': a.to_html(),
1024 <title>%(arttitle)s</title>
1025 <author><name>%(author)s</name></author>
1026 <link href="%(url)s/post/%(uuid)s" />
1027 <id>%(url)s/post/%(uuid)s</id>
1028 <summary>%(arttitle)s</summary>
1029 <published>%(ciso)sZ</published>
1030 <updated>%(uiso)sZ</updated>
1031 <content type="xhtml">
1032 <div xmlns="http://www.w3.org/1999/xhtml"><p>
1042 print 'Content-type: text/css\r\n\r\n',
1046 import cgitb; cgitb.enable()
1048 form = cgi.FieldStorage()
1049 year = int(form.getfirst("year", 0))
1050 month = int(form.getfirst("month", 0))
1051 day = int(form.getfirst("day", 0))
1052 tags = set(form.getlist("tag"))
1060 if os.environ.has_key('PATH_INFO'):
1061 path_info = os.environ['PATH_INFO']
1062 style = path_info == '/style'
1063 atom = path_info == '/atom'
1064 tag = path_info.startswith('/tag/')
1065 post = path_info.startswith('/post/')
1066 artlist = path_info.startswith('/list')
1067 comment = path_info.startswith('/comment/') and enable_comments
1068 if not style and not atom and not post and not tag \
1069 and not comment and not artlist:
1070 date = path_info.split('/')[1:]
1072 if len(date) > 1 and date[0]:
1074 if len(date) > 2 and date[1]:
1075 month = int(date[1])
1076 if len(date) > 3 and date[2]:
1081 uuid = path_info.replace('/post/', '')
1082 uuid = uuid.replace('/', '')
1084 t = path_info.replace('/tag/', '')
1085 t = t.replace('/', '')
1086 t = urllib.unquote_plus(t)
1089 uuid = path_info.replace('/comment/', '')
1090 uuid = uuid.replace('#comment', '')
1091 uuid = uuid.replace('/', '')
1092 author = form.getfirst('comformauthor', '')
1093 link = form.getfirst('comformlink', '')
1094 captcha = form.getfirst('comformcaptcha', '')
1095 body = form.getfirst('comformbody', '')
1097 db = ArticleDB(os.path.join(data_path, 'db'))
1099 articles = db.get_articles(tags = tags)
1100 articles.sort(reverse = True)
1101 render_atom(articles[:10])
1105 render_html( [db.get_article(uuid)], db, year, enable_comments )
1107 articles = db.get_articles()
1108 articles.sort(cmp = Article.title_cmp)
1109 render_artlist(articles, db)
1111 form_data = CommentFormData(author.strip().replace('\n', ' '),
1112 link.strip().replace('\n', ' '), captcha, body)
1113 article = db.get_article(uuid)
1114 captcha = Captcha(article)
1117 if not form_data.author:
1118 form_data.author_error = 'please, enter your name'
1121 link = valid_link(form_data.link)
1123 form_data.link = link
1125 form_data.link_error = 'please, enter a ' \
1128 if not captcha.validate(form_data):
1129 form_data.captcha_error = captcha.help
1131 if not form_data.body:
1132 form_data.body_error = 'please, write a comment'
1135 error = validate_rst(form_data.body)
1136 if error is not None:
1137 (line, desc, ctx) = error
1138 form_data.body_error = 'error at line %d: %s' \
1142 c = article.add_comment(author, body, link)
1144 cdb = CommentDB(article)
1145 cdb.comments = article.comments
1147 redirect = blog_url + '/post/' + uuid + '#comment-' \
1149 render_html( [article], db, year, enable_comments, redirect,
1152 articles = db.get_articles(year, month, day, tags)
1153 articles.sort(reverse = True)
1154 if not year and not month and not day and not tags:
1155 articles = articles[:10]
1156 render_html(articles, db, year)
1160 print 'Usage: %s {add|rm|update} article_path' % sys.argv[0]
1163 if len(sys.argv) != 3:
1168 art_path = os.path.realpath(sys.argv[2])
1170 if os.path.commonprefix([data_path, art_path]) != data_path:
1171 print "Error: article (%s) must be inside data_path (%s)" % \
1172 (art_path, data_path)
1174 art_path = art_path[len(data_path)+1:]
1176 db_filename = os.path.join(data_path, 'db')
1177 if not os.path.isfile(db_filename):
1178 open(db_filename, 'w').write('')
1179 db = ArticleDB(db_filename)
1182 article = Article(art_path, datetime.datetime.now(),
1183 datetime.datetime.now())
1184 for a in db.articles:
1186 print 'Error: article already exists'
1188 db.articles.append(article)
1191 comment_dir = os.path.join(comments_path, article.uuid)
1193 os.mkdir(comment_dir, 0775)
1195 if e.errno != errno.EEXIST:
1196 print "Error: can't create comments " \
1197 "directory %s (%s)" \
1199 # otherwise is probably a removed and re-added
1202 article = Article(art_path)
1203 for a in db.articles:
1207 print "Error: no such article"
1210 r = raw_input('Remove comments [y/N]? ')
1211 db.articles.remove(a)
1213 if enable_comments and r.lower() == 'y':
1214 shutil.rmtree(os.path.join(comments_path, a.uuid))
1215 elif cmd == 'update':
1216 article = Article(art_path)
1217 for a in db.articles:
1221 print "Error: no such article"
1223 a.updated = datetime.datetime.now()
1232 if os.environ.has_key('GATEWAY_INTERFACE'):
1235 sys.exit(handle_cmd())