Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install zeam.form.rdb

How to install zeam.form.rdb

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install zeam.form.rdb
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0b1
1.0.1Never BuiltWhy not?
1.0b1 Available View build log
Windows (64-bit)
1.0b1
1.0.1Never BuiltWhy not?
1.0b1 Available View build log
Mac OS X (10.5+)
1.0b1
1.0.1Never BuiltWhy not?
1.0b1 Available View build log
Linux (32-bit)
1.0
1.0.1Never BuiltWhy not?
1.0 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
Linux (64-bit)
1.0.1 Available View build log
1.0 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
 
License
BSD
Lastest release
version 1.0.1 on Jan 9th, 2014

zeam.form.rdb 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 ModelFields
from zeam.form.base import Form

class 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, ForeignKey
from sqlalchemy.types import Integer, String
from zeam.form.ztk.widgets.uri import URIField

idT_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',
          'foreignTitleColumn': 'Title'})
Name = Column(
    'Name',
    String(45),
    info={'minLength': 20,
          'maxLength': 45})
URL = Column(
    'URL',
    String(63),
    info={'title': u"URL",
          'description': u"Website URL"
          'factory': URIField,
          'defaultValue': 'http://github.com',
          'required': True})

For a ForeignKey, you have the possibility to provides multiple columns to foreignTitleColumn, and a function to be called to create the title as foreignTitleFactory, both in the info dictionnary. foreignTitleQuery can specified to refine the SQLAlchemy request used to obtain the title terms.

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.

Changes

1.0.1 (2012/12/12)
  • Fix title factory to support unicode values.
1.0 (2012/10/11)
  • Refactor not to rely any longer on zope.schema or megrok.rdb. SQLAlchemy Column's are directly converted to zeam form fields. This requires zeam.form.ztk 1.3 or higher.
  • Add tests on field generation.
1.0b2 (2012/06/21)
  • Add support for title_query to filter out terms in a generated ForeignKey vocabulary.
1.0b1 (2012/04/27)
  • Initial version.

Subscribe to package updates

Last updated Jan 9th, 2014

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.