procession/procession — pull request #14 by jaypipes (2014-01-17 05:46:11+00:00)
Title: Adds support for slug fields

Enhances the User model first, adding a user_name
column as well as a new slug column, slugified automatically
from user_name's value.

In order to reduce duplication of code and keep things DRY,
this patch adds a decorator that can be placed on any DB API
call that follows the get_$model_by_pk() pattern. This decorator
adapts the decorated function to look at the value of the supplied
primary key lookup value, and if the value does **not** look like
a UUID, then the decorator presumes it is a slug, and attempts to
look up the real primary key based on the slug.

This allows any model that has a slug attribute on it to be
looked up by primary key as well as the easier to understand and
remember slug value. Since the integration is entirely in the database
API, this means that any REST API call that has the pattern:

GET|PUT|DELETE /$model/{model_id}

will work just as well using a slug for {model_id} as a UUID.