Fetch a single row from the database or else trigger a 404.
Typical usage is to fetch a single row for display or editing:
class PageController(object):
@expose()
def index(self, id):
page = fetch_row(Page, id)
return page.name
@expose()
def works_with_slugs_too(self, slug):
page = fetch_row(Page, slug=slug)
return page.name
If the pk is string new then an empty instance of mapped_class is created and returned. This is helpful in admin controllers where you may reuse your edit action for adding too.
Parameters: |
|
---|---|
Returns: | An instance of mapped_class. |
Raises webob.exc.HTTPNotFound: | |
If no result is found |
Produce a URL-friendly string from the input.
XHTML entities are converted to unicode, and then replaced with the best-choice ascii equivalents.
Parameters: | string (unicode) – A title, name, etc |
---|---|
Returns: | Ascii URL-friendly slug |
Return type: | unicode |
Return a unique slug based on the provided string.
Works by appending an int in sequence starting with 2:
- awesome-stuff
- awesome-stuff-2
- awesome-stuff-3
Parameters: |
|
---|---|
Returns: | A unique slug |
Return type: | unicode |