My favorites | Sign in
Project Logo
                
Search
for
Updated Dec 12, 2008 by percious17
Labels: Phase-Implementation, Deprecated
Primitives  
dbsprockets primitives to create custom forms

Primitives

dbsprockets.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.

makeForm

makeForm 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 .

makeTable

And 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
Hosted by Google Code