changeset 72:c9bab68d00ac

* add handlers argument class default * pass full url to handler
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 08 Jul 2010 10:48:13 -0700
parents 0c98d1c2c6df
children e6055bf127eb
files bitsyblog/bitsyblog.py
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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)