# HG changeset patch # User Jeff Hammel # Date 1461277059 25200 # Node ID c7495fb7104562fad27a4af012930c00e2413cf9 # Parent 67e01fc5e3609c8fa0424e6c4b946481a9468119 more output diff -r 67e01fc5e360 -r c7495fb71045 bitsyblog/blog.py --- a/bitsyblog/blog.py Sun Feb 23 17:45:22 2014 -0800 +++ b/bitsyblog/blog.py Thu Apr 21 15:17:39 2016 -0700 @@ -1,15 +1,20 @@ -"""blog interfaces to data for bitsy""" +""" +blog models +""" +# imports import datetime import os +import sys import utils - from cStringIO import StringIO from glob import glob from pkg_resources import iter_entry_points + class BlogEntry(object): """interface class for a blog entry""" + def __init__(self, date, body, privacy, user, modified=None): self.date = date self.body = body @@ -70,7 +75,7 @@ blog.sort(key=lambda entry: entry.date, reverse=True) return blog[:number] - # interfaces for subclasses + ### interfaces for subclasses def blog(self, user, permissions, number=None): """ @@ -95,6 +100,7 @@ def delete(self, user, datestamp): """remove a blog entry""" + class FileBlog(Blog): """a blog that lives on the filesystem""" @@ -110,9 +116,15 @@ def get_entry(self, user, datestamp, permission): modified = datetime.datetime.fromtimestamp(os.path.getmtime(self.location(user, permission, datestamp))) - return BlogEntry(utils.date(datestamp), - self.body(user, datestamp, permission), - permission, user, modified=modified) + try: + return BlogEntry(utils.date(datestamp), + self.body(user, datestamp, permission), + permission, + user, + modified=modified) + except Exception: + sys.stderr.write("Error getting blog entry for datestamp: '{0}'\n".format(datestamp)) + raise ### interfaces from Blog