|
|
Archetypes Quick Reference Manual (Obsolete)
Note: Return to reference manual view.
A collection of quick reference document for Archetypes.
1.
Field Reference
When you are using Fields in a Schema, it is important to be aware of all the properties that are defined by default for Fields. The following table shows the properties of the Field class, which all specific Fields have a copy of or override. Refer to the specific Field reference further down to see which properties are redefined.
Feedback to: Maik Röder, roeder@berg.net
In the following table, the standard Field properties are shown in the first column. The next column shows their default value. When you know the defaults you can avoid redefining the properties with the same values as the default ones when you define your custom Fields. In the last column, you will find a description of what the property is about.
| Name |
Default |
Description |
| widget |
StringWidget |
The default widget is a StringWidget. Widgets are not given as a String, but as a reference to their class. Later, when the Field that contains the widget is instantiated, its widget attribute is set to an instance of the referenced StringWidget class. |
| schemata |
'default' |
You can use your own Schematas to deal with groups of Fields separately. The default Schemata is "default". For metadata Fields, the "metadata" Schemata is used. |
| mode |
rw |
The mode of a Field can include read and write access. Accessors will not be created without the read mode, and Mutators will not be created without the write mode. |
| read_permission |
View from CMFCorePermissions |
The View Permission, as defined in CMFCorePermissions, is used to check whether the current user is allowed to see the Field in read mode. Only interesting if the read mode is activated. The read permission is checked when rendering the widget in read mode. |
| write_permission |
ModifyPortalContent from CMFCorePermissions |
The ModifyPortalContent Permission, as defined in CMFCorePermissions, is used to check whether the current user is allowed to fill in the Field in write mode. Only interesting if the write mode is activated. The write permission is checked when rendering the widget in write mode. |
| vocabulary |
() |
List of possible values for the field. An instance of DisplayList is expected here, although the empty list, which is the default is accepted like this. |
| enforceVocabulary |
False |
Defines whether the vocabulary should be enforced. Before storing a value, it is double-checked that it is really part of the vocabulary. This is important so that no bogus values can be introduced. |
| searchable |
False |
Should this Field be indexed by the SearchableText method? If yes, the field will be searchable through the web even if the user which performs the search does not have the right to see the Field, so you have to take care that this is set correctly. |
| index |
None |
Syntax: # "KeywordIndex" or "<index_type>:schema". The index_type defines the type of index to use in the portal catalog to index this Field. If 'schema' is set, the Field will also become part of the Catalog MetaData, which means that it will appear in the Catalog search results. |
| required |
False |
Required Fields have to be filled in before submitting the form. If a Field is not required, it will be accepted even if it is empty. |
| validators |
() |
The validators can be given as a list or tuple of strings. If you only have one validator, you can give it as a string. |
| default |
None |
The default value for the field |
| default_method |
None |
String defining the class-method to call to obtain a default value |
| storage |
AttributeStorage() |
The default storage, AttributeStorage, stores values as an attribute of the instance. |
| mutator |
None |
The mutator names a method that changes the value of the Field. If you don't provide a special method name here, a default mutator that simply stores the passed in value is created. |
| accessor |
None |
The accessor names a method that returns the value of the Field. If you don't provide a custom method name here, a default accessor is going to be created that just returns the value of the Field. |
| edit_accessor |
None |
The edit_accessor returns the raw value of the field |
| multiValued |
False |
If a Field can have multiple values, this property should be set. This is the case for Fields that allow the selection of multiple values, like multiple selection lists. |
| isMetadata |
False |
Marks MetaData fields. This is currently only needed as a convenience for the filterFields method of Schema. |
| type |
None |
Provided by the Fields that derive from the base class Field. Should never be changed in a Schema. |
| generateMode |
veVc |
If 'c' is set, the accessors and mutators will be set on the class, if necessary. The modes 'v', 'e' and 'V' are currently out of use in Archetypes. There is usually no need to change this in your Schemas.. |
| force |
'' |
Currently not in use. May be used in the future. |
| index_method |
_at_accessor |
May be either _at_accessor, _at_edit_accessor or the name of a method which is used as accessor for the index.
|
| languageIndependent |
False |
Flag for Fields that are independent of the language, such as dates. This information
tells LinguaPlone that no translation is necessary for this field. |
CMF Object Field
Used for storing value inside a CMF Object, which can have workflow. Can only be used for BaseFolder-based content objects
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
FileWidget
|
Possible values:
|
| storage |
storage |
ObjectManagedStorage
|
|
| type |
|
object
|
|
Special properties
| Name |
Type |
Default |
Description |
| portal_type |
|
File
|
|
| workflowable |
|
True
|
|
| default_mime_type |
|
application/octet-stream
|
|
Date Time Field
Used for storing date/time
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
CalendarWidget
|
Possible values:
-
LabelWidget
-
CalendarWidget
(default)
|
| default |
datetime |
|
|
| type |
|
datetime
|
|
Reference Field
Used for storing references to other Archetypes Objects
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
ReferenceWidget
|
Possible values:
-
ReferenceWidget
(default)
-
LabelWidget
-
InAndOutWidget
|
| index_method |
|
_at_edit_accessor
|
|
| type |
|
reference
|
|
Special properties
| Name |
Type |
Default |
Description |
| vocabulary_custom_label |
|
|
|
| allowed_types_method |
|
|
|
| relationship |
|
|
Defines the type of relationship we want to establish with this Field. Examples are: 'KnowsAbout' or 'Owns'
|
| vocabulary_display_path_bound |
|
5
|
|
| allowed_types |
|
()
|
This list defines all Types that are searched to find objects that the user can make a reference to. It also specifies the Types that should be allowed to be added directly from the reference widget. This is only activated if the addable property is set.
|
| callStorageOnSet |
|
False
|
|
| referenceReferences |
|
False
|
|
| referenceClass |
|
Reference
|
|
Photo Field
Used for storing images. Based on CMFPhoto.
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
ImageWidget
|
Possible values:
|
| default |
string |
|
|
| type |
|
image
|
|
Special properties
| Name |
Type |
Default |
Description |
| displays |
|
{'medium': (480, 480), 'xlarge': (1024, 1024), 'large': (768, 768), 'xsmall': (200, 200), 'small': (320, 320), 'thumbnail': (128, 128)}
|
|
| default_content_type |
|
image/gif
|
|
| allowable_content_types |
|
('image/gif', 'image/jpeg')
|
|
Image Field
Used for storing images. Images can then be retrieved in different thumbnail sizes
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
ImageWidget
|
Possible values:
-
ImageWidget
(default)
-
LabelWidget
|
| default |
string |
|
|
| type |
|
image
|
|
Special properties
| Name |
Type |
Default |
Description |
| swallowResizeExceptions |
|
False
|
|
| primary |
|
False
|
|
| sizes |
|
{'thumb': (80, 80)}
|
|
| original_size |
|
|
|
| max_size |
|
|
|
| default_content_type |
|
image/png
|
|
| content_class |
|
|
|
| allowable_content_types |
|
('image/gif', 'image/jpeg', 'image/png')
|
|
Float Field
Used for storing float values
Different properties
| Name |
Type |
Default |
Description |
| default |
string |
0.0
|
|
| type |
|
float
|
|
String Field
Used for storing simple strings
Different properties
| Name |
Type |
Default |
Description |
| default |
string |
|
|
| type |
|
string
|
|
Special properties
| Name |
Type |
Default |
Description |
| default_content_type |
|
text/plain
|
|
Boolean Field
Used for storing boolean values
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
BooleanWidget
|
Implemented as a CheckBox.
Possible values:
-
LabelWidget
-
BooleanWidget
(default)
|
| default |
boolean |
|
|
| type |
|
boolean
|
|
Attachment Field
Used for storing files with advanced features.
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
FileWidget
|
Possible values:
|
| default |
string |
|
|
| type |
|
file
|
|
Special properties
| Name |
Type |
Default |
Description |
| primary |
|
False
|
|
| default_content_type |
|
application/octet
|
|
| content_class |
|
|
|
File Field
Used for storing files
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
FileWidget
|
Possible values:
-
FileWidget
(default)
-
LabelWidget
|
| default |
string |
|
|
| type |
|
file
|
|
Special properties
| Name |
Type |
Default |
Description |
| primary |
|
False
|
|
| default_content_type |
|
application/octet
|
|
| content_class |
|
|
|
Text Field
Used for storing text which can be used in transformations
Different properties
| Name |
Type |
Default |
Description |
| default |
string |
|
|
| type |
|
text
|
|
Special properties
| Name |
Type |
Default |
Description |
| primary |
|
False
|
|
| default_content_type |
|
text/plain
|
|
| content_class |
|
|
|
| allowable_content_types |
|
('text/plain',)
|
Used in the TextArea and Visual widget to let the user choose between different text formats in which the content is entered.
|
| default_output_type |
|
text/plain
|
This is only used on the get method, and decides to which MIME-Type the content is transformed if no special MIME-Type is demanded.
|
Integer Field
Used for storing integer values
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
IntegerWidget
|
Possible values:
-
LabelWidget
-
IntegerWidget
(default)
|
| default |
integer |
0
|
|
| type |
|
integer
|
|
Special properties
| Name |
Type |
Default |
Description |
| size |
|
10
|
The maximum length of the input field for Integers is 10.
|
Fixed Point Field
Used for storing fixed point values
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
DecimalWidget
|
Possible values:
-
LabelWidget
-
DecimalWidget
(default)
|
| validators |
validators |
isDecimal
|
|
| default |
string |
0.00
|
|
| type |
|
fixedpoint
|
|
Special properties
| Name |
Type |
Default |
Description |
| precision |
|
2
|
|
LinesField Field
Used for storing text which can be used in transformations
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
LinesWidget
|
Possible values:
-
KeywordWidget
-
LinesWidget
(default)
-
LabelWidget
-
MultiSelectionWidget
-
PicklistWidget
-
InAndOutWidget
|
| default |
string |
()
|
|
| multiValued |
boolean |
False
|
|
| type |
|
lines
|
|
Computed Field
Read-only field, which value is computed from a python expression
Different properties
| Name |
Type |
Default |
Description |
| widget |
widget |
ComputedWidget
|
Possible values:
-
LabelWidget
-
ComputedWidget
(default)
|
| storage |
storage |
ReadOnlyStorage
|
|
| type |
|
computed
|
|
| mode |
string |
r
|
|
Special properties
| Name |
Type |
Default |
Description |
| expression |
|
|
Evaluated on the object to compute a value.
|
2.
Widget Reference
Gives a quick overview of all properties of the default Archetypes 1.3.1 widgets.
Feedback to: Maik Röder, roeder@berg.net
Each Archetypes Field has a widget property defining the widget
to be used for the Field. Widgets only work together with certain
Fields.
Archetypes 1.3.1 Widget Reference
Feedback to: Maik Röder, roeder@berg.net
Each Archetypes Field has a widget property defining the widget
to be used for the Field. Widgets only work together with certain
Fields.
| Name |
Default |
Description |
| description |
|
The help text for this Field. It is rendered like this:
<div class="formHelp" tal:define="description python:widget.Description(here)" tal:content="structure description" tal:attributes="id string:${fieldName}_help" i18n:translate=""> Help </div>
|
| description_msgid |
"help_..." |
The i18n id for the help text. Usually used with a prefix of "help_", as in
"help_template_mixin".
|
| label |
|
The label of this field. It is rendered like this:
<label i18n:translate="" tal:content="python:widget.Label(here) + ':'"> Field </label>
|
| label_msgid |
"label_..." |
The i18n id for the label usually with a prefix of "help_", like "label_copyrights".
|
| visible |
{'edit':'visible', 'view':'visible'} |
Decides visibility in edit and view modes. There are three modes:
- visible: The widget is rendered.
- hidden: The field is rendered as a hidden field. For example, the creators
property is hidden in edit and view mode. The layout property is hidden in
view mode.
- invisible: Not rendered at all. For example, the id is not rendered in
view mode, and the creation_date and modification_date are invisible
in edit mode.
To define both edit and view visibility, you can also use the
following shorthands:
For visible:
- visible = True
- visible = 1
For hidden:
- visible = False
- visible = 0
For invisible:
|
| macro |
"widgets/..." |
The widget to be used for rendering. The widget page template is found in the widgets
subdirectory of the Archetypes skin. The following widgets are available: string,
decimal, integer, reference, computed, textarea, lines, boolean, calendar, selection,
multiselection, keyword, file, rich, zid, image, label, password, visual, epoz, inandout,
picklist.
|
| helper_css |
() |
A tuple containing a list of ids of .css files containing the CSS to
be included when rendering any Archetypes template that the widget
is a part of.
Just make sure that the files you are pointing to exist somewhere
in a skin layer, such as the custom layer or in a skin that is a
part of a product you are writing.
The Archetypes Page Templates base_edit.cpt, base_view.pt and
base_metadata.cpt will include the CSS contained in your helper
CSS as is.
|
| helper_js |
() |
A tuple containing a list of ids of .js files containing the
JavaScript to be included when rendering any Archetypes template
that the widget is a part of.
Just make sure that the files you are pointing to exist somewhere
in a skin layer, such as the custom layer or in a skin that is a
part of a product you are writing.
The Archetypes Page Templates base_edit.cpt and base_metadata.cpt
will include the JavaScript contained in your helper JavaScript as
is.
The use of helper JavaScript seems to be considered only helpful in
edit forms, so the base_view.pt template does not include the
JavaScript, although this may change in future versions of
Archetypes.
|
| postback |
True |
A boolean that decides whether this field is repopulated with a POSTed value
when an error occurs while editing. In general all fields are repopulated
when an error occurs, the only exception being the password widget, where
we want to start with a clear field when the password was not correct.
|
| populate |
True |
A boolean deciding whether this field should be populated in edit mode.
This is true for all widgets except for the password widgets, which are
usually not stored, but have to be entered manually.
|
| modes |
('view', 'edit') |
Used in view and edit screens to decide whether the widget is shown or not.
|
| show_content_type |
False |
Currently not used in Archetypes. Only true for FileWidgets.
|
| i18n_domain |
"plone" |
This property is not used in Archetypes templates, which are currently either
using the plone or the archetypes i18n domain. You may decide to support this
in your own templates, but you may also hard-code the domain.
One example where the i18n domain support really makes sense is for vocabularies,
which are depending on your problem domain. You can define the i18n_domain property on
the Widget or on the Field, just keep in mind that the i18n_property defined
on the Field takes priority.
|
|
|
|
StringWidget (widgets/string)
Renders a HTML text input box which accepts a single line of text
Special Properties
| Name |
Type |
Default |
Description |
| maxlength |
integer |
255
|
<input maxlength= |
| size |
|
30
|
<input size= |
TextAreaWidget (widgets/textarea)
Renders a HTML Text Area for typing a few lines of text
Special Properties
| Name |
Type |
Default |
Description |
| rows |
integer |
5
|
<textarea rows= |
| format |
|
0
|
? |
| cols |
integer |
40
|
<textarea cols= |
| append_only |
boolean |
False
|
Boolean that allows you to make an append-only TextArea widget. New text gets added to the top of the existing text, dividing the new text from the existing text using the divider property. The existing text is shown below the TextArea, and is not editable. This currently works with TextArea widgets and using plain text format. |
| divider |
string |
========================
|
Which divider to use for append only text areas. Only used then the append_only property is True. |
SelectionWidget (widgets/selection)
Renders a HTML selection widget, which can be represented as a dropdown, or as a group of radio buttons
Special Properties
| Name |
Type |
Default |
Description |
| format |
|
flex
|
Possible values: flex, select, radio. Uses radio buttons when set to radio, and a single-selection list when set to select. Using flex will automatically use single-selection lists for more than three settings at a time, and a single-select list for up to three settings. |
MultiSelectionWidget (widgets/multiselection)
Renders a HTML selection widget, where you can be choose more than one value
Special Properties
| Name |
Type |
Default |
Description |
| format |
|
select
|
Possible values: select, checkbox. Uses a either a checkbox or a multi-selection list. |
| size |
|
5
|
Defines the size of the multi-select list. Does not apply for checkboxes. |
BooleanWidget (widgets/boolean)
Renders a HTML checkbox
RichWidget (widgets/rich)
Renders a HTML widget that allows you to type some content, choose formatting and/or upload a file
Special Properties
| Name |
Type |
Default |
Description |
| rows |
integer |
5
|
Number of rows |
| format |
|
1
|
Apparently not used? |
| cols |
integer |
40
|
Number of columns |
| allow_file_upload |
|
True
|
Shows a file upload field under the text field. |
LinesWidget (widgets/lines)
Renders a HTML textarea for a list of values, one per line
Special Properties
| Name |
Type |
Default |
Description |
| rows |
integer |
5
|
Rows of the lines widget. |
| cols |
integer |
40
|
Columns of the lines widget. |
ReferenceWidget (widgets/reference)
Renders a HTML text input box which accepts a reference value
Special Properties
| Name |
Type |
Default |
Description |
| checkbox_bound |
|
5
|
When the number of items exceeds this value, multi-selection lists are used. Otherwise, radio buttons or checkboxes are used. |
| destination |
|
None
|
May be:- ".", context object;
- None, any place where Field.allowed_types can be added;
- string path;
- name of method on instance (it can be a combination list);
- a list, combining all item above;
- a dict, where {portal_type:} destination is relative to portal root
|
| addable |
|
False
|
Create createObject link for every addable type |
| destination_types |
|
None
|
Either a single type given as a string, or a list of types given as a string, defining what types we allow adding to. Only applies when addable is set on the widget. |
Different Properties
| Name |
Type |
Default |
| helper_css |
|
('content_types.css',)
|
IntegerWidget (widgets/integer)
Renders a HTML text input box which accepts a integer value
Special Properties
| Name |
Type |
Default |
Description |
| maxlength |
|
255
|
Maximum input size |
| size |
|
5
|
Size of the input field |
CalendarWidget (widgets/calendar)
Renders a HTML input box with a helper popup box for choosing dates
Special Properties
| Name |
Type |
Default |
Description |
| format |
|
|
Defines the strftime Format, e.g. '%d.%m.%Y' for the view. |
| future_years |
|
5
|
Not supported by the plone templates yet. |
| starting_year |
|
1999
|
Not supported by the plone templates yet. |
| ending_year |
|
None
|
Not supported by the plone templates yet. |
| show_ymd |
|
True
|
Not supported by the plone templates yet. |
| show_hm |
|
True
|
Not supported by the plone templates yet. |
Different Properties
| Name |
Type |
Default |
| helper_css |
|
('jscalendar/calendar-system.css',)
|
| helper_js |
|
('jscalendar/calendar_stripped.js', 'jscalendar/calendar-en.js')
|
IdWidget (widgets/zid)
Renders a HTML widget for typing an Id
Special Properties
| Name |
Type |
Default |
Description |
| display_autogenerated |
|
True
|
Not used any more. Instead, the "show_id" Python Script from plone_scripts is used to decide whether to show an id in an edit form. |
| is_autogenerated |
|
isIDAutoGenerated
|
Not used any more. Instead, the "isIDAutoGenerated" Python Script from plone_scripts is used to determine whether an id is autogenerated |
ImageWidget (widgets/image)
Renders a HTML widget for uploading/displaying an image
Special Properties
| Name |
Type |
Default |
Description |
| display_threshold |
|
102400
|
Only display the image inline if img.getSize() <= display_threshold |
Different Properties
| Name |
Type |
Default |
| show_content_type |
|
True
|
FileWidget (widgets/file)
Renders a HTML widget upload a file
Different Properties
| Name |
Type |
Default |
| show_content_type |
|
True
|
DecimalWidget (widgets/decimal)
Renders a HTML text input box which accepts a fixed point value
Special Properties
| Name |
Type |
Default |
Description |
| thousands_commas |
|
False
|
Shows commas for thousands. Edit "7632654849635.02", and it is displayed as "7,632,654,849,635.02". |
| whole_dollars |
|
False
|
Shows whole dollars in view, leaving out the cents. Enter "1.123", and "$1" is shown. |
| maxlength |
|
255
|
Maximum input size |
| dollars_and_cents |
|
False
|
Shows dollars and cents. Enter "123.123" and "$123.12" is shown. |
| size |
|
5
|
Size of the input field |
ComputedWidget (widgets/computed)
Renders the computed value as HTML
KeywordWidget (widgets/keyword)
Renders a HTML widget for choosing keywords
Special Properties
| Name |
Type |
Default |
Description |
| vocab_source |
|
portal_catalog
|
Defines the catalog to search for additional vocabulary to be combined with the vocabulary defined for the field. The Archetypes edit form uses the collectKeywords Python Script to bring together the additional and the predefined vocabulary. Additional keywords from existing content are found using catalog.uniqueValuesFor(fieldName). Additional keywords not added if the enforceVocabulary property of the Field is true. |
| roleBasedAdd |
|
True
|
Only shows the "New keywords" form for adding keywords if the current user has one of the roles stored in the allowRolesToAddKeywords property in the site_properties property sheet in portal_properties |
| size |
|
5
|
Size of the input field |
PasswordWidget (widgets/password)
Renders a HTML password widget
Special Properties
| Name |
Type |
Default |
Description |
| maxlength |
|
255
|
Maximum input size |
| size |
|
20
|
Size of the input field |
Different Properties
| Name |
Type |
Default |
| populate |
boolean |
False
|
| postback |
boolean |
False
|
| modes |
|
('edit',)
|
InAndOutWidget (widgets/inandout)
Renders a widget for moving items from one list to another. Items are removed from the first list.
Special Properties
| Name |
Type |
Default |
Description |
| checkbox_bound |
|
5
|
Not used. |
| destination |
|
None
|
See description for ReferenceWidget. |
| addable |
|
False
|
See description for ReferenceWidget |
| size |
|
6
|
Size of the select widget |
| destination_types |
|
None
|
See description for ReferenceWidget |
Different Properties
| Name |
Type |
Default |
| helper_css |
|
('content_types.css',)
|
| helper_js |
|
('widgets/js/inandout.js',)
|
EpozWidget (widgets/epoz)
Renders a HTML Epoz widget
Special Properties
| Name |
Type |
Default |
Description |
| format |
|
0
|
Apparently not used? |
| cols |
|
40
|
Number of columns |
| rows |
|
5
|
Rows of the textarea |
| append_only |
|
False
|
Currently not implemented. |
| divider |
|
========================
|
Currently not implemented. |
VisualWidget (widgets/visual)
Renders a HTML visual editing widget widget
Special Properties
| Name |
Type |
Default |
Description |
| format |
|
0
|
Apparently not used? |
| cols |
integer |
80
|
Number of columns of the Textarea. |
| height |
|
400px
|
Height of the edit form in pixel |
| rows |
integer |
25
|
Number of rows of the Textarea. |
| append_only |
|
False
|
Currently not implemented. |
| width |
|
507px
|
Width of the edit form in pixel. |
| divider |
|
|
Currently not implemented. |
LabelWidget (widgets/label)
Renders a HTML widget that only displays the label
PicklistWidget (widgets/picklist)
Render a widget to pick from one list to populate another. Items stay in the first list.
Special Properties
| Name |
Type |
Default |
Description |
| size |
|
6
|
description_PicklistWidget_size |
Different Properties
| Name |
Type |
Default |
| helper_js |
|
('widgets/js/picklist.js',)
|
|