84c33945856b33e8064b3e5422744f074dd2d491
1 # -*- coding: utf-8 -*-
4 Consists of functions to typically be used within templates, but also
5 available to Controllers. This module is available to both as 'h'.
7 # Import helpers as desired, or define your own, ie:
8 # from webhelpers.html.tags import checkbox, password
9 from webhelpers
import *
10 from routes
import url_for
, redirect_to
12 # Scaffolding helper imports
13 from webhelpers
.html
.tags
import *
14 from webhelpers
.html
import literal
15 from webhelpers
.pylonslib
import Flash
16 import sqlalchemy
.types
as types
20 def get_object_or_404(model
, **kw
):
21 from pylons
.controllers
.util
import abort
23 Returns object, or raises a 404 Not Found is object is not in db.
24 Uses elixir-specific `get_by()` convenience function (see elixir source:
25 http://elixir.ematia.de/trac/browser/elixir/trunk/elixir/entity.py#L1082)
26 Example: user = get_object_or_404(model.User, id = 1)
28 obj
= model
.get_by(**kw
)