Personal tools
You are here: Home Documentation Tutorials ArchGenXML 1.x- Getting started Basics: Attributes / Fields
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Basics: Attributes / Fields

How to control the fields of your schema.

Jens W. Klein

ArchGenXML is a code-generator for CMF/Plone applications (Products) based on the Archetypes framework. It parses UML models in XMI-Format (.xmi, .zargo, .zuml), created with applications such as ArgoUML, Poseidon or ObjectDomain. This tutorial will help you get started developing applications with the aid of ArchGenXML.
Page 6 of 17.

The schema of your content types, generated from the attributes of your model and their tagged values, contains Archetypes fields. Each field has a type and a widget. The Archetypes documentation and the quick reference at the end of this document describes which fields are available and what parameters they take as configuration.

usage of tagged values

If you set a tagged value on an attribute of your class, in general that tagged value will be passed through as a parameter to the generated Archetypes field. Hence, if you set a tagged value enforceVocabulary to the value 1 on an attribute, you will get enforceVocabulary=1 for that field in the generated schema. Similarly, you can set a field's widget properties by prefixing the tagged value with widget:. widget:label sets the label of a widget, for instance.

non-string tagged values

As before, when reading tagged values, ArchGenXML will generally treat them as strings, with a few exceptions where only non-string values are permitted, such as the required tagged value. If you do not wish your value to be quoted as a string, prefix it with python:. For example, if you set the tagged value default to python:["high", "low"] on a lines attribute, you will get default=["high", "low"] in a LinesField in your schema.

index in catalog

To create an index in portal_catalog for this field add the tagged value index with value FieldIndex. An FieldIndex with the name of the fields accessor (e.g. get) gets created.

Multiple indexes can be defined in a tuple, indexes for special catalogs can be prefixed with the catalog name following a / (e.g. python:("FieldIndex", "member_catalog/TextIndex"))

To include the index in catalog metadata (and have the attribute ready to use in the brain objects), append :brains (same as older :schema), (e.g. FieldIndex:brains)

field recycling - copy from parents schema and modify

You may need a Description field it is usally defined in your parent classes (BaseContent, BaseFolder) Schema, but it appears under properties-tab, not in your base_edit form. To make it show up there, you just need to change one property of the field: schemata = "default".

Solution: copy the field definition. in UML add an attribute to you class, give it the "type" copy and a tagged value schemata with value default. Setting values on copied-fields and their widgets is at some details different from a new field definition, so attention here.

 
by Jens W. Klein last modified September 11, 2007 - 22:44
Contributors: jensens, optilude, reinout, frisi, fifer, et al
All content is copyright Plone Foundation and the individual contributors.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by