Blogging on App Engine, part 6: Comments and Search
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
This is part of a series of articles on writing a blogging system on App Engine. An overview of what we're building is here.
Today we're going to tackle two separate issues: Support for commenting on posts, and support for search. Commenting is fairly straightforward, so we'll deal with that first.
Commenting
Rather than implement our own comments system, we're going to take advantage of an existing 'SaaS' commenting offering, Disqus. Disqus provides simple drop in Javascript powered comment support, and has, by now, a rather impressive feature set, incorporating support for various login schemes - their own, OpenID, facebook connect, twitter, and others - as well as advanced functionality like finding and displaying 'reactions' from social sites around the web along with comments from users.
Integrating disqus support is straightforward. Since some people might not want to use it, or might want to use an alternate system, however, we're going to use a new config setting to ensure we only enable it if it's wanted. Add the following to the bottom of config.py:
# To use disqus for comments, set this to the 'short name' of the disqus forum
# created for the purpose.
disqus_forum = None ...
Blogging on App Engine, part 5: Tagging
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
This is part of a series of articles on writing a blogging system on App Engine. An overview of what we're building is here.

Following on from our previous post, today we're going to deal with tagging. There are three components to adding tagging support to our blog:
- Adding tags to the model and the post/edit interface.
- Generating listing pages of posts with a given tag.
- Adding tags and links to the listing pages on individual posts.
We'll tackle these in order. First, adding tags to the model and to the add/edit post interface. Add the following property immediately after 'body' on the BlogPost class (in models.py):
tags = db.StringListProperty()
That's it. No, really. Thanks to our use of ModelForms, our admin interface now has support for adding and editing posts with tags. Try it, if you wish. One slight caveat: The interface expects tags to be separated by newlines, rather than by commas. That's something we could address with a custom widget, at a later stage.
Next, the listing pages. Nearly all the functionality required to generate listings of posts with a given tag is identical to that required to generate ...
Blogging on App Engine, part 4: Listings
Posted by Nick Johnson | Filed under tech, app-engine, coding, bloggart
As you may have surmised from previous posts in the series, the 'static serving' approach we're using can lead to regenerating a lot of pages at once. For a long lived blog, with lots of history, regenerating the archive pages could take a significant amount of time - potentially long enough that we could run into the 30 second request deadline when updating or adding a post. Fortunately, however, we have something custom-made for the purpose: the Task Queue API. Using the Task Queue API, we can take care of the essential updates immediately - the post page itself, for example - then queue up other updates, such as the archive pages, on the task queue for later execution. Using the task queue has the extra advantage that updates can be executed in parallel.
Even better, we can make use of a new library in version 1.2.5 of the SDK, called 'deferred'. deferred is a clone of Ruby's delayed::job library, and makes it easy to enqueue function and method calls on the App ...
Blogging on App Engine, part 3: Dependencies
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
Blogging on App Engine Interlude: Editing and listing
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
Blogging on App Engine, part 2: Basic blogging
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
Blogging on App Engine, part 1: Static serving
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
Win a Dell Netbook and $1000 of App Engine credit!
Posted by Nick Johnson | Filed under coding, app-engine, tech
Just a quick note: We recently announced a competition on the App Engine blog: Develop an App Engine app that uses Twilio, and you could win a Dell Netbook and $1000 of App Engine credit! Twilio is an excellent service that lets you write sophisticated telephony applications, entirely over HTTP.You have until October 4th to enter. I really wish I could, but as part of the team, I'm disqualified. ;)
Writing a blog system on App Engine
Posted by Nick Johnson | Filed under coding, app-engine, tech, bloggart
I'm going to spend the next few posts working through the process of writing a simple, robust and scalable blogging system for App Engine. This first post is going to be fairly dull, unfortunately, as it will serve to cover what our requirements and non-requirements are, and the general approach we're going to take to achieve those objectives. In other words: Lots of bullet points, and little to no code. Don't worry, it'll get more exciting soon.
First, let's outline what we (or at least, I) expect out of a blogging system:
- Simple authoring. I personally don't want to juggle with WYSIWYG HTML editors in order to write blog posts - I prefer to enter markup directly. But at the same time, I don't intend to make all potential users conform to the same expectations - so we should be able to support rich text editors if they're desired.
- Good isolation of code and markup. Users shouldn't have to understand the innards of our blogging software if all they want to do is change how the blog looks or is laid out.
- RSS and Atom support. This should go without saying, these days ...
Handling file uploads in App Engine
Posted by Nick Johnson | Filed under coding, app-engine, cookbook, tech
This is the ninth in a series of 'Cookbook' posts describing useful strategies and functionality for writing better App Engine applications.One issue that comes up frequently on the App Engine groups is how to handle file uploads from users. Part of the confusion arises from the fact that App Engine apps cannot write to the local filesystem. Fortunately, the Datastore comes to the rescue: We can easily write an app that accepts file uploads and stores them in the datastore, then serves them back to users.
To start, we need an HTML form users can upload files through:
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form method="post" action="/">
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
</body>
</html>
We'll also need a datastore model we can store the uploaded file in:
class DatastoreFile(db.Model):
data = db.BlobProperty(required=True)
mimetype = db.StringProperty(required=True)
And finally, a Request Handler that can handle the uploads:
class UploadHandler(webapp.RequestHandler):
def get(self):
self.response.out.write(template.render("upload.html", {}))
def post(self):
file = self.request.POST['file']
entity = DatastoreFile(data=file.value, mimetype=file.type)
entity.put()
file_url = "http://%s/%d/%s ... Newer Older