# HG changeset patch # User Jeff Hammel # Date 1278611293 25200 # Node ID c9bab68d00ac23341b1483fd229e63e21ac19072 # Parent 0c98d1c2c6dfd0d836e75dd7b0c4ab57f93baf92 * add handlers argument class default * pass full url to handler diff -r 0c98d1c2c6df -r c9bab68d00ac bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Thu Jul 08 10:40:43 2010 -0700 +++ b/bitsyblog/bitsyblog.py Thu Jul 08 10:48:13 2010 -0700 @@ -56,6 +56,7 @@ 'auto_reload': 'True', # reload the genshi templates 'help_file': None, # help to display 'feed_items': 10, # number of RSS/atom items to display + 'post_handlers': '' # post handlers } @@ -107,15 +108,16 @@ self.newuser = self.users.new # post handlers + self.post_handlers = [ i for i in self.post_handlers.split() if i ] self.handlers = [] # handlers for blog post event for entry_point in iter_entry_points('bitsyblog.listeners'): - try: - handler = entry_point.load()(self, **handler_args.get(entry_point.name, {})) - self.handlers.append(handler) - except: - print 'Cant load entry point %s' % entry_point.name - continue - + if entry_point.name in self.post_handlers: + try: + handler = entry_point.load()(self, **handler_args.get(entry_point.name, {})) + self.handlers.append(handler) + except: + print 'Cant load entry point %s' % entry_point.name + raise ### methods dealing with HTTP @@ -337,13 +339,13 @@ # write the file now = utils.datestamp(datetime.datetime.now()) - location = self.user_url(request, user, now) + location = self.user_url(request, user, now, permalink=True) blog_entry = self.blog.post(user, now, body, privacy) # fire event handlers # XXX could be done asynchronously for handler in self.handlers: - handler(blog_entry) + handler(blog_entry, location) # point the user at the post return exc.HTTPSeeOther("Post blogged by bitsy", location=location) @@ -446,7 +448,6 @@ if permanant: application_url = request.application_url else: - application_url = urlparse(request.application_url)[2] path = [ application_url ] + list(path) return '/'.join(path)