Mercurial > hg > bitsyblog
changeset 69:bcc3a59713c3
1st steps to have blog post entry handler plugins
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 07 Jul 2010 13:58:21 -0700 |
parents | 3550159184cf |
children | f6a6a4b072e7 |
files | bitsyblog/blog.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bitsyblog/blog.py Mon Jun 28 08:07:09 2010 -0700 +++ b/bitsyblog/blog.py Wed Jul 07 13:58:21 2010 -0700 @@ -5,6 +5,7 @@ from cStringIO import StringIO from glob import glob +from pkg_resources import iter_entry_points class BlogEntry(object): """interface class for a blog entry""" @@ -46,6 +47,14 @@ class Blog(object): """abstract class for a users' blog""" + def __init__(self): + self.handlers = [] # handlers for blog post event + for entry_point in iter_entry_points('bitsyblog.listeners'): + try: + handler = entry_point.load() + self.handlers.append(handler) + except: + continue def __call__(self, user, permissions=('public',), number=None): return self.blog(user, permissions, number=number) @@ -78,7 +87,9 @@ def post(self, user, date, text, privacy): """post a new blog entry""" - + entry = BlogEntry(date, body, privacy, user): + for handler in self.handlers: + handler(entry) def delete(self, user, datestamp): """remove a blog entry""" @@ -87,6 +98,7 @@ """a blog that lives on the filesystem""" def __init__(self, directory): + Blog.__init__(self) self.directory = directory def location(self, user, permission, *path):