The basic Comment functionality seems to be working on this site (not than anyone has actually left any real comments yet).
Working with the Users API
I'm in the midst of working on an admin page for myself so I can delete comments, add site API keys, etc. This lead me towards dealing with authenticating admin users. Of course, Google has this all taken care of already thanks to the Users API.
Here's the code for handling the admin page for the Comment Engine:
class AdminPage(webapp.RequestHandler): def get(self, action): if action == 'logout': self.redirect(users.create_logout_url('/admin/')) user = users.get_current_user() if user: if users.is_current_user_admin(): self.response.out.write('I am an admin!') else: self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(user.email() + ' is not a valid Administrator'); else: self.redirect(users.create_login_url(self.request.uri))
Pretty easy, huh?
Here's how it works
Handle the URL /admin/logout by logging out the current user
- The user is redirected back to the admin page after logout
If we're not logging out, grab the current user and see if it's actually a valid object
If the current user isn't a valid object, redirect to the login url
- This hands the user off to logging into Google Accounts which means that Google is handling all of the annoying stuff with account creation/management.
- After they log into Google Accounts, they come right back to the admin page
Once the user is logged in, check to see if they're an Admin for the application
- Again, Google handles this via the Developer section of the AppEngine application configuration page.
- You just add a list of Google Accounts that are allowed to administrate the application.
And, voila! I have an admin page that, currently, only I have access to.
Weirdness with Indexes
I did run into one bit of strangeness related to Indexes.
I've been doing development on a couple of different machines (a desktop & a laptop). I'd noticed the index.yaml file but hadn't really paid much attention to it since it seemed to be auto-generating what it needed and I wasn't having any issues.
Until last night.
Suddenly, out of no where, a bunch of my previous GET queries started throwing NeedIndexError exceptions.
I spent some time poking around and noticed that my application config on appgengine.google.com only listed one Index for the application while my local copy of index.yaml actually had 4 auto-generated Indexes listed.
I did another update to send my local copy of the app up to the App Engine but that didn't seem to be updating the Indexes on the live app.
In the end, I had to manually move all of my Index out of the AUTOGENERATED area of index.yaml.
Once I'd done that and resynced the app, everything started working again.