This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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):
...    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
Release History

Release History

0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
megrok.z3cform.composed-0.1.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256 Source Oct 27, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting