What's new? | Help | Directory | Sign in
Google
dbsprockets
A pythonic way to generate widgets from database definition.
  
  
  
  
    
Show all Featured Downloads:
groksprox.tar.gz
Links:
Blogs:
Groups:

DBSprockets

The goal of DBSprockets is to give the developer the power to simply generate web content from available database definitions. Because DBSprockets relies heavily on Toscawidgets, it is framework-independent. It is easy to implement forms on TG, TG2, Pylons, Zope, and Grok using DBSprockets' primitives.

DBSprockets is mainly supporting SQLAlchemy, so any application you have that uses SQLAlchemy will be well supported. Support for other ORMs will be available in the future.

Every component of DBSprockets is extensible so that the developer can override a form or a set of forms to his or her liking.

One of the important implementations using DBSprockets is DBMechanic, which acts as a control board for your database crud.

Current Version

0.2.2, 0.5dev

Dependent on

Supported Frameworks

Installation

If you don't already have easy_install setup download ez_setup here. And execute it.

With easy_install:

easy_install dbsprockets

more details.

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'])

More information about the demoModel .

which when displayed looks like this:

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 looks something like this:

Notice that the town_id has been replaced with the actual name of the town automatically.

Extensible API

The power of DBSprockets is that every part of it is extensible so customizing forms, widget templates and other portions of your database view is made easier. Simply override the fields you want to change by name or type with what you want. Want a whole set of sprockets that have the same modification? No problem, create a Sprockets cache with your new defaults.

more on DBSprocketsAPI

DBMechanic

Started as a replacement for Catwalk that works with Sqlalchemy.

DBMechanic is a stand-alone TG2 controller for database viewing.

Usage

DBMechanic is easy to use! Here is an example of how to use it in TG 1.0:

from myproject.model import metadata
from dbsprockets.dbmechanic.frameworks.tg import DBMechanic
from dbsprockets.saprovider import SAProvider

dbmechanic = DBMechanic(SAProvider(metadata), '/dbmechanic')

more on DBMechanic