zeam.form.rdbExtra SQLAlchemy support for zeam.form | |
Download |
zeam.form.rdb Ranking & Summary
Advertisement
- License:
- BSD License
- Price:
- FREE
- Publisher Name:
- Sylvain Viollon
- Publisher web site:
- http://github.com/thefunny42/
zeam.form.rdb Tags
zeam.form.rdb Description
zeam.form.rdb is a Python module that provides an helper to generate form fields for zeam.form.base, using zeam.form.ztk fields from an SQLAlchemy model.To accomplish, you must create your fields using the descriptor ModelFields in your form. It will automatically fetch the context of the form, and generate the fields accordingly, caching them (for performance reasons).Example:from zeam.form.rdb import ModelFieldsfrom zeam.form.base import Formclass MyForm(Form): label = "Test form" fields = ModelFields()In your SQLAlchemy schema, you can use the extra dictionnary info to control the widget generated. Foreign key will generate a choice of possible values to select, using the column you desire as title.Example:from sqlalchemy import Column, ForeignKeyfrom sqlalchemy.types import Integer, Stringfrom zope import schemaidT_Effort = Column( 'idT_Effort', Integer, primary_key=True, info={'title': u"Identifier"})idT_Opportunity = Column( 'idT_Opportunity', Integer, ForeignKey('T_Opportunity.idT_Opportunities'), info={'title': u'Opportunity', 'title_column': 'Title'})Name = Column( 'Name', String(45))URL = Column( 'URL', String(63), info={'title': u"URL", 'schema': schema.URI})For a ForeignKey, you have the possibility to provides multiple columns to title_column, and a function to be called to create the title as title_factory, both in the info dictionnary.A field will be required unless the column is nullable, or the option required is given through info.title and description from info will be used as well in order to create the form field.Product's homepage
zeam.form.rdb Related Software