changeset 105:67e01fc5e360

STUB: bitsyblog/bitsyblog.py bitsyblog/factory.py bitsyblog/user.py
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Feb 2014 17:45:22 -0800
parents 3198edbf7d8e
children c7495fb71045
files bitsyblog/bitsyblog.py bitsyblog/factory.py bitsyblog/user.py
diffstat 3 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/bitsyblog.py
+++ b/bitsyblog/bitsyblog.py
@@ -249,19 +249,17 @@ class BitsyBlog(object):
         else:
             content = self.write_blog(user, blog, request.path_info, n_links, request)
             content_type = 'text/html'
 
         # return the content
         return Response(content_type=content_type, body=content)
 
     def get(self, request):
-        """
-        respond to a get request
-        """
+        """respond to a get request"""
 
         # front matter of the site
         index = self.get_index(request)
         if index is not None:
             return index
 
         # user space
         user, path = self.userpath(request)
@@ -332,18 +330,18 @@ class BitsyBlog(object):
         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:
           try:
             handler(blog_entry, location)
-          except: # XXX bare except!
-            pass
+          except Exception as e: # XXX bare except!
+              print ("Error processing {}: {}".format(handler, e))
 
         # point the user at the post
         return exc.HTTPSeeOther("Post blogged by bitsy", location=location)
 
     def put(self, request):
         """
         PUT several blog entries from a file
         """
@@ -567,17 +565,17 @@ class BitsyBlog(object):
         links = [(self.link(request), '/')]
         user = self.authenticated(request)
         if user:
             links.extend([(self.user_url(request, user), user),
                           (self.user_url(request, user, 'post'), 'post'),
                           (self.user_url(request, user, 'preferences'), 'preferences'),
                           (self.link(request, 'logout'), 'logout')])
         else:
-            links.extend([(self.link(request, 'login'), 'login'), 
+            links.extend([(self.link(request, 'login'), 'login'),
                           (self.link(request, 'join'), 'join')])
 
         if hasattr(self, 'help'):
             links.append((self.link(request, 'help'), 'help'))
 
         request.environ['data']['links'] = links
 
 
--- a/bitsyblog/factory.py
+++ b/bitsyblog/factory.py
@@ -52,16 +52,18 @@ def basebitsierfactory(global_conf, bits
     secret = bitsyblog_args.get('secret', 'secret')
     auth = BitsyAuth(HTTPExceptionHandler(app),
                      global_conf,
                      app.passwords,
                      newuser=None,
                      site=bitsyblog_args.get('site', 'bitsyblog'),
                      secret=secret)
     if not user in app.users:
+        # create a new user
+        # really, should go in CLI or what not
         pw = getpass('Enter password for %s: ' % user)
         app.newuser(user, auth.hash(app.user, pw))
     return auth
 
 
 def bitsierfactory(global_conf, **app_conf):
     """make single-user bitsyblog"""
     bitsyblog_args, handler_args = get_args(app_conf, BitsierBlog)
--- a/bitsyblog/user.py
+++ b/bitsyblog/user.py
@@ -31,17 +31,17 @@ class BitsyUsers(object):
     def __iter__(self): return self.users()
 
     def __contains__(self, user):
         return user in self.users()
 
     def __getitem__(self, user):
         """return a user"""
         if user not in self.users():
-            raise KeyError
+            raise KeyError("User '{}' not found".format(user))
         user = BitsyUser(user, self.password(user))
         user.settings = self.settings(user.name)
         return user
 
     def passwords(self):
         """returns a dictionary of { user: password }"""
         passwords = {}
         for user in self.users():