Mercurial > hg > bitsyblog
changeset 106:c7495fb71045
more output
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 21 Apr 2016 15:17:39 -0700 |
parents | 67e01fc5e360 |
children | c5b9c9ba42eb |
files | bitsyblog/blog.py |
diffstat | 1 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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