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


This module gives you an abstract base class to make CRUD forms with. These forms give you by default a tabular view of the objects, where attributes of the object can be edited in-place. Please refer to the ICrudForm interface for more details.

>>> from megrok.z3cform.crud import crud

Form registration


We set up some models to serve as a form context:

>>> import grokcore.component as grok
>>> from zope import interface, schema

>>> class IPerson(interface.Interface):
...    name = schema.TextLine(title=u"Name")
...    age = schema.Int(title=u"Age")

>>> class Person(grok.Context):
...    grok.implements(IPerson)
...    name = schema.fieldproperty.FieldProperty(IPerson['name'])
...    age = schema.fieldproperty.FieldProperty(IPerson['age'])
...    def __init__(self, name, age):
... = name
...        self.age = age

>>> class IPersonContainer(interface.Interface):
...    pass

>>> class PersonContainer(dict):
...    grok.implements(IPersonContainer)

For this test, we take the the name of our persons as keys in our storage:

>>> storage = PersonContainer()
>>> storage['Peter'] = Person(u'Peter', 16)
>>> storage['Martha'] = Person(u'Martha', 32)

We declare the Form with the help of megrok.z3cform.base. It’s very similar to a grok.View:

>>> import megrok.z3cform.base as z3cform

>>> class TestForm(crud.CrudForm):
...    grok.context(IPersonContainer)
...    update_schema = IPerson
...    def get_items(self):
...        return sorted(storage.items(), key=lambda x: x[1].name)
...    def add(self, data):
...        person = Person(**data)
...        storage[str(] = person
...        return person
...    def remove(self, (id, item)):
...        del storage[id]

Grokking and querying

We let Grok register the component:

>>> grok.testing.grok_component('form', TestForm)

Now, we can query it normally:

>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()

>>> from zope.component import getMultiAdapter
>>> myform = getMultiAdapter((storage, request), name="testform")

>>> myform
<TestForm object at ...>
>>> print myform()
<form action="" method="post"
        enctype="multipart/form-data" class="form-testform">



  • Initial release
Release History

Release History


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.crud-0.1.tar.gz (8.3 kB) Copy SHA256 Checksum SHA256 Source Jul 9, 2012

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