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 dm.zope.generate

How to install dm.zope.generate

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

This package contains code generators to facilitate the development of Zope[2] applications.

Modules

constructor

This module contains factories for the generation of add form and add action for OFS.PropertyManager.PropertyManager based classes. The generated functions are usually used as constructors in registerClass calls during product initialization.

The class' _properties attribute and the associated default values are used for add form generation.

The module tries hard to avoid encoding problems. Its functions need to handle up to 3 encodings: the encoding used for the code, the encoding used for non unicode properties and unicode properties. The browser can only handle a single encoding per page. Therefore, the module must use a single encoding and all other encodings must be mapped. The module uses utf-8 as this unified encoding. The module does nothing special with strings from code. The page template will convert it to unicode in its standard way. Use unicode strings, if this gives not the expected result. Unicode based properties are passed on unchanged to the template. str based properties are mapped to unicode with a charset that is either explicitely specified, looked up in the current acquisition context under the name management_page_charset and falls back to ZPublisher.default_encoding. The form action converts values for those properties back to str using the same charset.

add_form_factory

This factory generates an add form for an OFS.PropertyManager.PropertyManager subclass. It has the following parameters.

name default description
class_   the class to generate the form for
action add_classname the forms action
description class_.__doc__ the documentation shown in the form
charset see above  
template package provided the template to generate the form

The template it brought into the acquisition context of the generated functions argument and then called with the keyword parameters charset, meta_type, description, action, properties and class_. The call should return the HTML form representation. The package provided template works well together with the add action created by the add action factory.

When you plan to customize the template, please take a look at the package provided template and the docstring in the source as this page does not describe all details.

Due to a bug/weakness, Zope's property management page handles unicode properties only correctly when it can use the utf-8 charset. Therefore, it is highly recommended to use utf-8 consistently. Otherwise, it is possible that property values set with functions of this module cannot be reliably edited later.

add_action_factory

This factory generates an add action for an OFS.PropertyManager.PropertyManager subclass. The generated action creates an instance of this class, sets its properties, adds it as content object of its first parameter (assumed to be an OFS.ObjectManager.ObjectManager) and optionally calls a hook. Then, it either returns the created instance or redirects to its management interface.

The factory has the parameters class_ and the optional hook.

The generated action has the parameters id and the optional props and REQUEST.

props specifies property values for the created instance. If not specified and REQUEST is passed, it defaults to REQUEST.form. If specified, it must be a mapping. If the property value mapping lacks values for some properties, these retain their default values; values for undefined properties are silently ignored.

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

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.