Stickum - A TurboGears based Pastebin
Recently, pastebin.com has been having performance issues and I’ve been struggling to find an alternative that does syntax highlighting in enough languages to satisfy my needs. I tend to sit in #turbogears a lot and help people new to TurboGears when I can and a pastebin is invaluable in that situation.
From this need, Stickum was born. It’s a very simple TurboGears application that accepts pastes and… well, pastes them, and it does syntax highlighting for a variety of languages so it’s not just for Pythonistas.
SimpleBlog - Part 2
In our last adventure we created the skeleton of a simple blogging application using SQLAlchemy as the ORM. In part 2 we are going to look at using Foreign Keys and create a method of allowing comments.
If you need the simpleblog files from the end of Part 1 they can be found here.
SimpleBlog - Part 1
I’ve noticed a lot of people asking questions about SQLAlchemy in the #turbogears channel on Freenode and the TurboGears mailing list, and there aren’t that many step-by-step tutorials in using TG and SA so I decided to write one.
The tutorial will be published in two sections; Part 1 will cover the basics and part 2 will extend part 1 to cover a few of the trickier aspects of creating a project with SA.
Back with the world!
I never quite realised how much I depended on the Internet for communication, entertainment and information before my internet connection at home went down the pan.
Now I’m back up and running with a tasty ADSL2 connection (running at about 5Mb) and I’m over the moon. Never before has a simple light made anyone happier - the router’s “I’m-synced-with-the-line-and-connected” light. Yes, I know… such a technical term.
Disabling users instead of deleting.
I came across a use case where I needed to disable users without actually deleting them so a user could continue to be associated with their data and reinstated at a later date.
At first I thought that I’d need to roll my own Identity Provider but I came up with a method that is slightly easier to implement.
I added a BoolCol to the auto-generated TurboGears User Class:
Class User(SQLObject):
...
disabled = BoolCol(default=False)
...
I then changed the classmethod that SOProvider uses to get the user from the database to raise an SQLObjectNotFound when a user’s “deleted” flag is set to True.
@classmethod
def by_user_name(self, text):
try:
u = self.by_email_address(text)
except SQLObjectNotFound:
raise
if u.disabled:
raise SQLObjectNotFound
else:
return u
Note that this classmethod has also been modified to return users by email address.
This way user can effectively be disabled as they can no longer log in successfully. It’s cheating outrageously because raising an SQLObjectNotFound exception is clearly lying to the SOProvider, but it works effectively.

