Remove exceptions for entries_dir

This commit is contained in:
Stefan Ritter 2011-02-07 23:06:10 +01:00
parent c46d219390
commit 50e5c532f7
1 changed files with 15 additions and 21 deletions

View File

@ -216,30 +216,24 @@ if cname and ctext and ctitle:
else: else:
comments_file = os.path.join(entries_dir, ctitle + ".comments") comments_file = os.path.join(entries_dir, ctitle + ".comments")
if not os.path.exists(comments_file): if not os.path.exists(comments_file):
try: content = open(comments_file, "w")
content = open(comments_file, "w")
content.close()
except:
errorpage("\"%s\" isn\'t writable!" % entries_dir)
try:
content = open(comments_file, "a")
content.write("-." + cname + "\n")
content.write("+." + time.strftime("%c", time.localtime()) + "\n")
ctext = ctext.split("\n")
for line in ctext:
content.write("." + line + "\n")
content.close() content.close()
# Send mail? content = open(comments_file, "a")
if not new_comment_mail == "False": content.write("-." + cname + "\n")
msg = "From: Blogthon\nTo: %s\nSubject: New comment on %s\n\nSomeone wrote a comment to this entry: %s?p=%s" % (mail_to, blog_title, blog_url, ctitle.replace(" ", "-")) content.write("+." + time.strftime("%c", time.localtime()) + "\n")
smtp = SMTP(smtp_host) ctext = ctext.split("\n")
smtp.starttls() for line in ctext:
smtp.sendmail(blog_title, mail_to, msg) content.write("." + line + "\n")
content.close()
# Send mail?
if not new_comment_mail == "False":
msg = "From: Blogthon\nTo: %s\nSubject: New comment on %s\n\nSomeone wrote a comment to this entry: %s?p=%s" % (mail_to, blog_title, blog_url, ctitle.replace(" ", "-"))
smtp = SMTP(smtp_host)
smtp.starttls()
smtp.sendmail(blog_title, mail_to, msg)
smtp.quit() smtp.quit()
except:
errorpage("Comment cannot be written!")
# Read entries and store their title and timestamp # Read entries and store their title and timestamp
entries = [] entries = []