| Author ArchGenXML: | Phil Auersperg <phil@bluedynamics.org> |
|---|---|
| Author Documentation: | Jens W. Klein <jens.klein@jensquadrat.de> |
| Date: | 2004-03-03 |
| Version: | 1.4 |
| Web site: | http://sourceforge.net/projects/archetypes |
| Original URL: | http://plone.org/documentation/archetypes/archgenxml-manual/ |
ArchGenXML is a commandline utility that generates Plone applications (products) based on the Archetypes framework from UML models using XMI (.xmi, .zargo, .zuml) and XSD (XMLSchema) files.
Design your Archetypes (code for content objects in plone) offline using a UML design tool like Poseidon or ObjectDomain. Export the UML to XMI or XSD and use ArchGenXML to generate Phyton code for use as a Product. This new Product is available as a new item (document) type in the Plone userinterface.
This time the tool is not round-trip enabled: Generated code can't be back-converted into XMI. But you can re-generate over existing code: The Method bodys are kept.
UML - the Unified Modelling Language is a graphical language designed to describe software.
To attain that goal this language has got several different diagram-types defined. An overview about them gives the OOSE (german and a english pdf). Our interest is mainly on class diagrams. An article about class diagrams is at Developer.com andanother comprehensive site about it you'll find at The Official Agile Modeling (AM) Site.
For ArchGenXML are from interest: the class-diagramm and it's different associations. In future versions of ArchGenXML it may be possible to define the workflow with state diagrams.
With this language you're able to define object-oriented data-models. A class is the outline of an object like a building-plan. With ArchGenXML you define this plan. If a building is related to other building you define this with associations.
ArchGenXML is tested with the XMI output from the following tools:
Requirements: You need an recent Archetypes with all it's dependencies (see Archetypes README) and PyXML for older Python versions.
It's tested with Plone 2.0.x and Archetypes 1.2.x and later
Install an UML-Tool on your local workstation. For our examples we used the ObjectDomain Evaluation Version. At the moment we tend to commend Poseidon CE.
Get latest ArchGenXML Release or grab the latest developer sketch from CVS:
cvs -d :pserver:anonymous@cvs.sf.net:/cvsroot/archetypes co ArchGenXML
See also README file in ArchGenXML!
The usage is:
python ArchGenXML.py -o <target> [ options ] <xmi-source-file>
OPTIONS:
-o <target>
Output file directory path for data representation classes. Last part
is used for internal directory namings.
-P <name1>,<name2>...
names of packages to parse in source file
-a --actions
generates actions (default)
--no-actions
do not generates actions
--method-preservation
methods in the target sources will be preserved (default)
--no-method-preservation
methods in the target sources will be preserved
-t --unknown-types-as-string
unknown attribute types will be treated as text
--ape-support
generate apeconf.xml and generators for ape (needs Archetypes 1.1+)
--i18n-support
support for i18NArchetypes. Attributes with a stereotype 'i18n' or a
taggedValue 'i18n' set to '1' are multilingual.
--creation-permission=<perm>
specifies which permission to create content default:Add [project]
content
--detailled-creation-permissions
seperate creation permissions per class
--no-module-info-header
do not generate module info header
--author=<string>
set default author string for module info headers, taggedValue will
override this
--e-mail=<string>
set default e-mail adress string for module info headers, taggedValue
will override this
--copyright=<string>
set default copyright string for module info headers, taggedValue will
override this
--licence=<string>
set default licence string for module info-headers, taggedValue will
override this
Example:
./ArchGenXML.py -o MyNewProduct mynewproduct.xmi
First we start with a simple example describing how to generat your first simple ArcheType out of an UML. Create a new class diagram. Create a new class. Add some attributes. No assigned value defaults to a string-field. The example also has an image-field and field containing a floating-point number.

You can download this example here as XMI-File or ObjectDomain-File.
Now export it to XMI or .zargo.
Start ArchGenXML generating python code:
./ArchGenXML.py -a yes -o ArchGenSimpleExample ArchGenSimpleExample.xmi
Now a folder exists containing the Product. Move or link this Folder to your zope-instance product directory. Restart zope. Go to to the portal_quickinstaller tool and add the new Product ArchGenSimpleExample. Thats it. Now you have a new content-type available to your Plone.
A complex example using all ArchGenXML capabilities to show what is possible.
ProjectWe have a class Project with a field (attribute) description with the Type Expression text.
It's rendered by default with the TextAreaWidget. But if you want to use Epoz,
VisualEditor or such nice stuff we have to change it to the VisualWidget.
Create a new tagged value called widget and give it the value VisualWidget.

We also define some operations. First a simple method: countTasks.
It contains its code as an tagged value code. You can add some documentation too.
It's written to the method code too.

You can also define the parameters given to the method in UML:

Also it's possible to define views for the ArcheType. An operation having the tagged value view generates an action.

The Class Resource is marked as abstract and the Classes Person, Room are inherited from it.
It means Resource isn't an addable object. It is just used to inherit from. Person and Room are getting a field description.

The arrows indicating the inheritance are placed by selecting the Generelization Tool and drag from Person or Room to Resource (see figure overview above).
By defining references you get a field to select a referenced class. Referenced objects can be moved inside the site and references still working.
You can define the Multiplicity of aggregated and referenced classes.
The following multiplicity is supported:
N - N is not supported.
Instead of editing 'Extensions/Install.py' you should place a new file 'AppInstall.py'. Define one or both methods out of 'install' and 'uninstall' and put you additional code in here. They are called after the automatic installation process via 'CMFQuickInstallerTool' (or old school style: calling External methods).
Tagged Values are used to add different behaviors to a class:
For tagged values starting with 'python:' the code after ':' is taken, otherwise a triple quoted string.
A list of all possible expressions for attributes and it's default settings.
All tagged values of a attribute will be converted into extended attributes for the archetypes field; i.e. you can define 'widget', 'storage', searchable, ... to overwrite defaults or set additional.
At tagged value i18n on an attribute have the same effect as stereotype i18n.
Methods are generated from UML-Code if you want that. You can also generate over an existing Python-File and ArchGenXML will keep the code of existing methods untouched.
Actions are generated by default you can turn it off by running ArchGenXML with parameter --no-actions. You can define all nessecary values via ArchGenXML.
Defines parameters of the method. Unused for action, view or form.
If 'action name' below is mentioned it is the name of the method with stereotype action, view or form unless no tagged value 'action', 'view' or 'form' is defined (depending on the stereotype).
Set permission for:
By defining an aggregation your archetype will become folderish. Only aggregated objects are allowed to residate in the folder.
There are two types of aggregation with different behaviors: