ArchGenXML Reference Card

Quick ArchGenXML / UML bindings reference card.

ArchGenXML Reference Card

Standard Elements

Stereotypes

« stub »

Applies to: Package, Class, Attribute, Method

By giving your class the « stub » stereotype, you can prevent it from being generated at all.

This is useful if you wish to show content types which are logically part of your model, but which do not belong to your product.

For instance, you could create a stub for Plone's standard Image type if you wish to include this as an aggregated object inside your content type - that is, your content type will become folderish, with Image as an allowable contained type.

Constraints

Tagged Values

widget:description_msgid

Override the default description message id (i18n).

widget

Applies to: LinkEnd, Attribute

    Applies to : LinkEnd

Widgets

widget:label

Set the label of a widget.

widget:label

widget:description

Set the widget's description.

widget:label_msgid

Override the default label message id (i18n).

widget:i18n_domain

Set the i18n domain (defaults to the product name).

widget:type

The name of your chosen widget type, such as StringWidget or SelectionWidget.

Widgets

default:widget:FIELDNAMEABBREVIATION

To change a the widget used for one field-type for the whole model, a product, a package or just for all fields in one class you can set on mode, product, package or class level the tagged value default:widget:FIELDNAMEABBREVIATION to WIDGETNAME.

For example use the tagged value default:widget:Reference and set it to ReferenceBrowserWidget to use the ReferenceBrowserWidget instead of the ReferenceWidget.

default:widget:reference

imports

Applies to : Package, Class

Additional python packages imports lines.

For a Package, imports statements will be added for each enclosed Class.

imports

    # from ReferenceCard/ReferenceCardPackage/ClassA.py

    # additional imports

    from ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget

Comment

Its only utility is in UML modeller : your diagram will me easily to read if well-commented.

Interface

Interfaces are a way of formally documenting the public interface to your code. By convention, they are usually in the interfaces package (see below).

Interfaces do not have most of the added fluff that content types do - they do not even have method bodies.

They do, however, have extensive documentation.

A class is said to "realise" an interface when it provides implementations for the methods defined in the interface.

The UML realisation arrow (a dotted line with an empty arrowhead) will ensure that your content types are linked to the correct interfaces by way of the __implements__ class attribute.

Classes / Content-Types

Name

Model

Name

Package

Bring order to your code.

Packages are both a UML concept and a Python concept.

In Python, packages are directories under your product containing a set of modules (.py files).

In UML, a package is a logical grouping of classes, drawn as a large "folder" with classes inside it.

To modularise complex products, you should use packages to group clases together.

Classes / Content-Types

Name

Class

Classes / Content-Types

Name

Tagged Values

import_from

Derive from other Product.

If you want to derive from a class of an other product create a stub class with a tagged value 'import_from': This will generate a import line from VALUE import CLASSNAME in classes derived from this class.

base_class

All content types in Archetypes are derived from one of the base classes - BaseContent, BaseFolder, OrderedBaseFolder and so on.

If you wish to turn this off, for example because the base class is being inherited from a parent class, you can set the base_class tagged value to 0.

Stereotypes

<>

A portal tool is a unique singleton which other objects may find via getToolByName and utilise.

There are many tools which ship with Plone, such as portal_actions or portal_skins.

Method

To create a method in your class, add a method to the UML diagram, with the desired parameters. The types of the parameters and the type of the return value are ignored, since Python does not support this.

Stereotypes

Archetypes uses actions and forms for generating custom tabs for accessing data of an Archetype object.

ArchGenXML can generate actions and forms for you: Just define a method without any parameters and set its stereotype accordingly.

<

>

<>

<>

Actions Tagged Values

Tagged values can be set on the sterotyped methods in order to set some properties of the action.

action

The TAL expression representing the action to be executed when the user invokes the action. Defaults to the methodname.

category

The category of an action, view or form. Defaults to object.

id

The id of an action, view or form. Defaults to the methodname.

label

The label of an action, view or form. Defaults to the methodname.

permission

permission=My permission results in 'permissions': ('''My Permission''',).

See the description of the general permission tagged value above for more.

condition

A TALES expression giving a condition to control when the action is to be made available.

form

see action.

view

see action.

Tagged Values

Alter how the code for the method is generated

code

Sets the python code body of the method. Only use this for short one-liners. If you fill in code manually in the generated files, method bodies will be preserved when you re-generate the product from the UML model.

documentation

Content of the python doc-string of the method. You can also use the documentation feature of most UML modellers to set documentation strings.

permission

Applies to methods with public visiblity only.

If you set the permission tagged value to My custom permission results in security.declareProtected("""My custom permission""",methodname) - that is, access to your method is protected by the permission with the name My custom permission.

If you want to use the CMF core permissions, add an imports tagged value to the method's class containing from Products.CMFCore import CMFCorePermissions, and then set the permission tagged value of your method to python:CMFCorePermissions.View, python:CMFCorePermissions.ModifyPortalContent or any other core permission.

You can also use the common paradigm of defining permissions in config.py as constants with names like EDIT_PERMISSION. With newer versions of ArchGenXML, a config.py is automatically generated and its contents imported, so you can just set the permission tagged value to, for example, python:EDIT_PERMISSION.

Attribute

Name

Field Types

http://plone.org/documentation/tutorial/archgenxml-getting-started/archgenxmlquickref

string

text

float

integer

reference

References as class attributes.

Relationships between classes and objects

file

date

image

lines

fixedpoint

boolean

richtext

selection

multiselection

photo

backreference

computed

Tagged Values

accessor

defines the accessor of a field

required

defines whether a field should be rendered required, or not.

  1. .. field is required
  2. .. field is not required

searchable

register and index the field in the catalog,

  1. .. register and index
  2. .. don't register and index

default_method

storage

AttributeStorage(), SQLStorage(), ....

sizes

vocabulary

defines the vocabulary or the method generating a vocabulary

allowed_types

defines the allowed types in a ReferenceField

relationship

defines the relationship, used in a ReferenceField

multiValued

defines whether a SelectionField accepts one or more values,

  1. .. multivalued
  2. .. singlevalued

enforceVocabulary

Attributes / Fields

default

Realization

Realize an interface

Inheritance

Inheritance allows to create an "expansion" of a class. It permits to more specific objects to use a generic class, plus a inherited one, what offers more attributes and methods.

Directed Association

A directed association identifies a relation container-contained, using a uni-directionnal relation between classes (by default, relations are bi-directionnal).

Name

Aggregation

Aggregation means: This content can exist global and in this container. The container class that gets the empty rhomb attached is derived from BaseFolder and it's allowed_content_types is set to the class that is attached to it.

Name

Composition

Compositions are used to model parts that exist or live and die with their associated owner. So the code generated is similair to the one generated by aggregations, but with one major difference:

The attached classes are only allowed to be generated in the folderish type of the class they're attached to.

Name

LinkEnd

Name

Association-class

Association-classes are not supported by ArchGenXML.

Créé par gpernot
Dernière modification jeudi 25 janvier 2007 11:42