|
Primitives
dbsprockets primitives to create custom forms
Primitivesdbsprockets.primitives is intended to allow the programmer create only the form associated with the SA object they are using. This is a very powerful approach to creating forms, not unlike newforms in Django, but it does have it's limitations. makeFormmakeForm provides a function for creating a Toscawidget based on a SQLAlchemy Model. Take a look a the simplest example, a login form: from dbsprockets.primitives import makeForm from myProject.myModel import User loginForm = makeForm(User, identifier='myLoginForm', action='/login', limitFields=['user_name', 'password']) Here is what the form looks like:
More information about the demoModel . makeTableAnd here is an example showing what it looks like to display a list of users: from dbsprockets.primitives import makeTable, getTableValue
from myProject import User
value = getTableValue(User)
table = makeTable(User, '/', omittedFields=['user_id', 'created', 'password'])
table(value=value)Which when rendered through a web framework looks something like this:
Notice that the town_id has been replaced with the actual name of the town automatically. |
Sign in to add a comment