Skip to main content

Grok based form framework

Project description

Summary

zeam.form.base is a form framework for Zope. It has common goals and purposes with formlib or z3c.form but tries to:

  • define small sane and reusable components : you don’t need a full flavored form to render and display only few widgets in your application,

  • be easily customizable without using hundreds of adapters: most of settings are set with properties on your form/fields,

  • prevent ZCML declarations by using Grok to register the few needed adapters (widgets and widgets value extractors),

  • always keep the context untouched: the form works on a content that can be something else than the context, it can even be a dictionnary. That means everywhere in the form, including in widgets, and actions, you can either access the context as the real context of the form, and have a way to access the content that the form is working on. This helps greatly if you have complicated widgets working, including when they are embedded in other widgets (like in a list or a table),

  • let people easily change form templates, by using megrok.pagetemplate by default, selecting which fields goes where they want,

  • let people define easily their widgets, and use them,

  • be able to create complex forms, like composed or table forms, where each form can modify the data it needs without having to hack-o-refresh other sub-forms: all actions are executed before any widget compute its value to render,

By default, it is unware of things like Zope-schema. Generating fields from a Zope-schema would be done with the help of zeam.form.ztk.

It work with Python 2.4, 2.5 and 2.6 (tested in Zope 2.10, 2.12 and Grok 1.0, 1.1).

Example

Let’s define a quick example. Actions can be defined standalone:

from zeam.form.base import Action, SUCCESS

class MailAction(Action):

   def available(self, form):
       return form.context.haveMailHost()

   def __call__(self, form):
       # Send a mail
       form.status = u"Mail sent"
       return SUCCESS

And included as attributes to the form:

class MailForm(Form):
   label = u"Send a mail"
   description = u"to people"
   fields = Fields(Field(u'Name'), Field(u'E-mail'), Field(u'Message'))
   actions = Actions(MailAction(u'Send mail'))

(A decoractor can be used on a form method as well if you don’t need lot of code for your action).

For more information

You can refer to the functional and doctest included in the package. Since it tries to be composed of small components, there is many way to put them together.

Changelog

1.0rc1 (2010/07/05)

  • The ExtractData method has been splitted in two, with the introduction of the validateData method, that allows the form to override the global form validation process. This lets the fields validation at the very same place, and only involves the general form validation process.

  • Created a new marker subclass for the form modes. This marker class defines a boolean allowing or not the extraction of the affected component, while the form is processed. Added tests for it.

  • Look for entry points zeam.form.components before adapting items into components in collection. This let you register adapters before they are used.

1.0b4 (2010/06/22)

  • Now the ‘Errors’ class can be used as a logical grouping of ‘Error’ and it stacks, in this case. Added tests to demonstrate and fix the behavior.

1.0b3 (2010/06/04)

  • Fixed the way the identifiers are generated. Now, empty prefixes are no longer generating malformed ids/names. Added tests to fix that behavior.

1.0b2 (2010/05/13)

  • Fix a bug in FormData initialization.

  • Add a NO_CHANGE marker.

1.0b1 (2010/05/03)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeam.form.base-1.0rc1.tar.gz (27.9 kB view details)

Uploaded Source

File details

Details for the file zeam.form.base-1.0rc1.tar.gz.

File metadata

File hashes

Hashes for zeam.form.base-1.0rc1.tar.gz
Algorithm Hash digest
SHA256 7aa596b65126c29a37b64db99cdb1bae8a5de3800b47d876db9cf182188f78e4
MD5 b565e0db3c5cefce7ce332ba2c636b1f
BLAKE2b-256 ee983d615c3d0e6334ae3db273f0c3dac170865696ceb2504132ae6be7ac365f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page