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.

pypm install megrok.z3ctable

How to install megrok.z3ctable

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install megrok.z3ctable
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.5.0 Available View build log
1.4.2 Available View build log
Windows (64-bit)
1.5.0 Available View build log
1.4.2 Available View build log
Mac OS X (10.5+)
1.5.0 Available View build log
1.4.2 Available View build log
Linux (32-bit)
1.5.0 Available View build log
1.4.2 Available View build log
Linux (64-bit)
1.5.0 Available View build log
1.4.2 Available View build log
Lastest release
version 1.5.0 on Feb 1st, 2011

The megrok.z3ctable package is a wrapper around the z3c.table components. z3c.table allows you to define HTML tables as zope3 components, defining columns as multi adapters.

Thanks to megrok.z3ctable, these components are now fully available in Grok, making them easy to declare and configure. The following components are available :

  • Table
  • Column
  • Value

Beyond a simple wrapping, megrok.z3cform brings you new convenient ways to create pages displaying a table:

  • TableView: a simple browser view displaying a table.
  • TablePage: a table browser view included in a layout (see megrok.layout)

For more information and more detailed examples please look in the tests directory of this package.

Getting started

First, we grok the package grokkers:

>>> import grokcore.component as grok
>>> from grokcore.component import testing
>>> from grokcore.component.testing import grok_component
>>> testing.grok('megrok.z3ctable')

Test Setup

Let's create simple items to demonstrate the package. Here, the table will be the representation of a folder listing, displaying (in an ordered way), the content of a simple container:

>>> from megrok.z3ctable.tests import Container, Content
>>> from zope.container import btree
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()

Let's create 2 dummy content:

>>> christian = Content('Christian', 29)
>>> trollfot = Content('Trollfot', 27)

Then, we instanciate a container and store the 2 dummies inside:

>>> container = Container()
>>> container['christian'] = christian
>>> container['trollfot'] = trollfot

A simple Table

We define a simple table. Here, the component only registers itself, there's no logic defined inside:

>>> from megrok.z3ctable import Table, Values
>>> from megrok.z3ctable import ITable

>>> class SimpleTable(Table):
...    """ My Simple Table """

>>> ITable.implementedBy(Table)

Let's make an instance of the Table:

>>> myTable = SimpleTable(container, request)
>>> ITable.providedBy(myTable)

Now, we need to feed our table with contents. In order to provide a pluggable way to fetch the content, z3c.table proposes an adapter called "Values". It is in charge of getting in the data to display:

>>> class MyValues(Values):
...     grok.adapts(btree.BTreeContainer, None, SimpleTable)
...     @property
...     def values(self):
...         return self.context.values()

We grok the MyValues Adapter:

>>> grok_component('MyValues', MyValues)

>>> myTable.update()
>>> myTable.render()

There is currently no output this is because the table itself contains no logic. The data is displayed by components called "Column". A Column is a multi adapter, adapting the context, the request and the table. It permits a very flexible handling of the tables and the data representations. Let's define a simple Column:

>>> from zope.interface import Interface
>>> from megrok.z3ctable import NameColumn
>>> from megrok.z3ctable import table
>>> class Names(NameColumn):
...     grok.context(Interface)
...     table(SimpleTable)

Now we grok our Column:

>>> grok_component('Names', Names)

and render the Table again:

>>> myTable.update()
>>> print myTable.render()

Here you go. A fully functional and pluggable table. Enjoy.


1.5.0 (2011-01-31)

  • Adapted the grokkers for the latest versions of martian and grokcore.component.

1.4.2 (2010-05-07)

  • Migration from Dolmen's GIT to Zope's Subversion repository. MANIFEST has been removed while a license file has been added. megrok.z3ctable is under the ZPL license.

1.4.1 (2010-02-21)

  • Cleaned out all the zope.app dependencies. Removed unused imports and re-structured the tests module. We are now using minimal dependencies.
  • megrok.z3ctable now requires zope.component >= 3.9.1. This means you have to use the latest ZTK KGS in your buildout. This KGS can be included via the groktoolkit.

1.4.0 (2010-01-16)

  • Now using ztk versions and fixed it for z3c.table >= 0.8

1.3.0 (2009-09-24)

  • Now Columns have their own grokker. Before that, they were treated as basic multi adapters. We now use a dedicated grokking component with explicit directives that can be auto-linked to context and table components. Read the test "test_implicit" in the ftests for more details. [trollfot]

1.2.1 (2009-09-18)

  • Add a new test for a template in a form [cklinger]

1.2.0 (2009-09-17)

  • Let megrok.z3ctable work with grokcore.view 1.12.2 [cklinger]

1.1.0 (2009-09-19)

  • Adapted megrok.z3ctable to the new version of megrok.layout and grokcore.view [cklinger]

Subscribe to package updates

Last updated Feb 1st, 2011

Download Stats

Last month:6

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.