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 megrok.z3cform.composed

How to install megrok.z3cform.composed

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install megrok.z3cform.composed
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
 
License
GPL
Lastest release
version 0.1 on Jan 5th, 2011

megrok.z3cform.composed is a package dedicated to define and register composed forms. Composed forms are forms built from a collection of sub forms.

megrok.z3cform.composed is based on z3c.form and megrok.z3cform.base.

Getting started

We import the needed dependencies:

>>> import grokcore.view as grok
>>> import megrok.z3cform.composed
>>> from megrok.z3cform.composed import ComposedForm, SubForm

We import the components utilities:

>>> from zope.component import getMultiAdapter
>>> from zope.publisher.browser import TestRequest

Defining a composed form

Context

A form needs a context. Let's create a simple model for test purposes:

>>> class MyContent(object):

System Message: ERROR/3 (<string>, line 37)

Inconsistent literal block quoting.

... pass

Declaration
>>> class Form(ComposedForm):
...   grok.context(MyContent)
Registration
>>> grok_component('composed', Form)
True
Query
>>> content = MyContent()
>>> request = TestRequest()
>>> composed = getMultiAdapter((content, request), name="form")
>>> composed
<megrok.z3cform.composed.tests.Form object at ...>
>>> composed.subforms
[]
>>> composed.updateForm()
>>> composed.subforms
[]

Defining sub forms

Declaration
>>> class SubFormOne(SubForm):
...     grok.context(MyContent)
...     megrok.z3cform.composed.order(2)
...     megrok.z3cform.composed.view(Form)
>>> class SubFormTwo(SubForm):
...     grok.context(MyContent)
...     megrok.z3cform.composed.order(1)
...     megrok.z3cform.composed.view(Form)
Registration
>>> grok_component('one', SubFormOne)
True
>>> grok_component('one', SubFormTwo)
True
Query
>>> composed.subforms
[]
>>> composed.updateForm()
>>> composed.subforms
[<megrok.z3cform.composed.tests.SubFormTwo object at ...>, <megrok.z3cform.composed.tests.SubFormOne object at ...>]
>>> for sub in composed.subforms:
...   print sub.prefix, sub.parentForm
subformtwo <megrok.z3cform.composed.tests.Form object at ...>
subformone <megrok.z3cform.composed.tests.Form object at ...>

Changelog

0.1 (2009-10-27)
  • Initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:2

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.