Dexterity uses zope.schema.interfaces for its fields reference. Which means that technically, this documentation as of current is also relevant for Zope3/Bluebream developers explicitly. Also, please note the following documentation follows the beautifully structured organization (in table format) on Archetype fields for Plone by Mikko Ohtamaa located at the following url: http://plone.org/documentation/manual/developer-manual/archetypes/fields/fields-reference. It also includes some of the default apidoc that is clearly useful which is currently copyrighted to the Zope Corporation and subsequent contributors. As well as bits from Chapter 8 (Zope Schemas and Forms) from the Zope 3 Developer's Handbook written by Stephan Richter. Including obvious addition and compilation from myself, Christopher Warner. It follows zope.schema.interfaces version 3.6.0 as of today April 30, 2010. I should also note that I plan to follow where ever Dexterity and Plone lead so in the future the idea that this works with everything may, indeed, change.
Unfortunately, this documentation is required as the primary recommendation "For a complete listing of the schema/field API, see the API documentation tool at http://localhost:8080/++apidoc++ or see the zope.schema.interfaces module". Doesn't provide a good enough web reference for the budding Zope/Bluebream and/or Plone developer. The following url; http://docs.zope.org/zope3/Code/zope/schema/_field/ is a bit more helpful. However it's a pain to traverse or see ready made examples. So, I need a decent formatted reference that I can readily refer to in printed format for myself. The below will be a WIP (Work-In-Progress) until it meets my needs, so if you see an error or want to provide an example please don't hesitate. Summarily, the reader should expect a corresponding widget reference in the near future. Last but not least, the following has also been provided to you by the Institute for the Study of the Ancient World @ New York University since I am here at work right now.
These attributes are common to nearly all fields. Field-specific attributes follow, and are listed by field. Particular fields have different defaults, types and some other specialized attributes.
Common Field Attributes
| Name |
Type |
Description |
Possible Values |
Default |
| bind |
method |
The name of a class method that returns a copy of the field which is bound to context.
The copy of the Field will have the 'context' attribute set to 'object'. This way a Field can implement more complex checks involving the object's location/environment.
Many fields don't need to be bound. Only fields that condition validation or properties on an object containing the field need to be bound |
An object from Plone you are working on; for example, context.Object |
None |
| title |
TextLine |
A short summary or label of the field which is used when displaying the corresponding field widget. |
A title for the fieldname, for example; "Firstname" |
None |
| description |
Text |
A short description of the field used for ToolTips and advanced help. |
"This is the first name of our User" |
None |
| required |
Bool |
This is a bool that tells whether a field is required or not. |
"True or False" or "0 or 1" |
True |
| readonly |
Bool |
This is a bool that tells whether the field is readonly or not if true the field's value cannot be changed. |
"True or False" or "0 or 1" |
False |
| default |
Depends on the field |
The default value may be None or a legal field value |
"None" or another "Field" |
|
| missing_value |
Object |
The missing_value exists if input for the Field is missing, and that's ok |
"None" or another "Field" |
|
| order |
Int |
The order attribute can be used to determine the order in which fields in a schema were defined. If one field is created after another (in the same thread), it's order will be greater. This is not normally set manually, since it is automatically assigned when an interface is initialized. The order of the fields in a schema is by default the same as the order of the fields in the Python code. |
"1" or "2" or "3" |
Required, Read-Only, Automatically Generated |
| constraint(value) |
method |
Checks a customized constraint on its passed value argument. You can implement this method with your Field to require a certain constraint. This relaxes the need to inherit/subclass a Field when you can add a simple constraint. Returns true if the given value is within the Field's constraint. |
Example here |
|
| validate(value) |
method |
Validates that the given passed argument is a valid field value. Returns nothing but raises an error if the value is invalid. It checks everything specific to a Field and also checks with the additional constraint. |
Example here |
|
| get(object) |
method |
Gets the value of the field for the given object argument |
Example here |
|
| query(object, default=None) |
method |
Queries the value of the field for a given object. Returns the default of None if the value hasn't been set |
Example here |
|
| set(object, value) |
method |
Sets the value of the field for a given object. If the field is readonly raises a TypeError |
Example here |
|
ASCII
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| ASCII |
Field |
This is a field containing a 7-bit ASCII string. No characters greater than 127 (DEL chr) are allowed. For a full list of available characters please visit the following url: http://www.unicode.org/charts/PDF/U0000.pdf |
"This is an ASCII string of characters\n" |
None |
ASCIIWidget |
ASCII Schema example code
from zope import schema
from zope import interface
class Demo (interface.Interface):
"ASCII Field declaration"
ascii_demo = schema.ASCII(
title = u'ASCII FIELD',
description = u'An Ascii Field',
)
|
|
ASCIIWidget example
|
|
ASCIILine
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| ASCIILine |
Field |
This field is the exact same as the ASCII field with the exception that it strips newlines |
"This is an ASCII string of characters" |
None |
ASCIIWidget |
ASCIILine Schema example code
from zope import schema
from zope import interface
class Demo (interface.Interface):
"ASCIILine Field declaration"
asciiline_demo = schema.ASCIILine(
title = u'ASCIILine FIELD',
description = u'An Asciiline Field',
)
|
|
|
Bool
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Bool |
Field |
A Boolean Field provides a default bool type of T or F, 1 or 0, Yes or No etc |
None, T, F |
None, T, F |
BooleanWidget |
Bytes
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Bytes |
Field |
A Field containing a byte string whose value can be constrained by the length operator. It's important to note that the byte string is in your default locale and that you made need to decode from that locale depending on your use case |
Byte String, "This is a default-locale byte string\n" |
|
BytesWidget |
BytesLine
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| BytesLine |
Field |
Same as a Bytes Field with the exception that this strips newline characters. |
Byte String, "This is a default-locale byte string" |
None |
BytesWidget |
Choice
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Choice |
Field |
A Field whose value is contained in a predefined set. Either with a Source, ContextSourceBinder or BaseVocabulary object that provides values for this field. Or a TextLine value |
|
None |
ChoiceWidget |
Date
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Date |
Field |
A field containing a date |
04/05/2012 |
None |
DateWidget |
Datetime
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Datetime |
Field |
Date and Time field, which takes the Date and time, to learn about datetime values please read the following PDF: http://dotat.at/tmp/ISO_8601-2004_E.pdf |
DATETIME |
None |
DatetimeWidget |
Decimal
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Decimal |
Field |
A Field containing a Decimal |
1.23 |
None |
DecimalWidget |
Dict
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Dict |
Field |
A Field containing a conventional dict. The key_type and value_type fields allow specification of restrictions for keys and values contained in the dict. |
dict = {'one':1, 'two':2, 'three': 3, 'four': 4} |
|
DictWidget |
DottedName
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| DottedName |
Field |
Derived from the BytesLine field, the DottedName field represents valid Python-style dotted names (object references). This field can be used when a valid and resolvable Python dotted name is required. |
|
|
DottedNameWidget |
Float
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Float |
Field |
Field containing a float value |
123.456789 |
None |
FloatWidget |
FrozenSet
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| FrozenSet |
Field |
Field containing a value that implements the API of a conventional Python 2.4+ frozenset |
set = (this, is, a set) |
None |
FrozenSetWidget |
Int
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Int |
Field |
A field containing an integer value |
12345 |
None |
IntWidget |
Id
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Id |
Field |
A field containing a unique identifier that is either an absolute URI or a dotted name. If it's a dotted name, it should have a module/package name as prefix. |
http://cwarner.kernelcode.com/uri OR module.package.dotted.name |
None |
IdWidget |
Len
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Len |
Field |
A field requiring its value to have a length. The value needs to have a conventional __len__ method. |
25 |
None |
LenWidget |
MinMax
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| MinMax |
Field |
A field requiring its value be between a minimum and maximum |
|
None |
|
MinMaxLen
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| MinMaxLen |
Field |
A field requiring the length of its value be within a range |
|
None |
|
Object
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Object |
Field |
A Field containing an Object value |
Object |
None |
|
Password
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Password |
Field |
A Field containing a unicode string without newlines that is a password |
password = '12345' |
None |
|
Set
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Set |
Field |
A Field containing a value that implements the API of a Python 2.4+ set. |
|
None |
|
SourceText
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| SourceText |
Field |
A Field containing the source text of an object |
|
None |
|
Text
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Text |
Field |
A Field containing a unicode string |
"Please make all of your strings unicode\n" |
None |
TextWidget |
TextLine
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| TextLine |
Field |
Same as a Text Field except it strips any newlines |
"Please make all of your strings unicode" |
None |
TextWidget |
Time
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Time |
Field |
Field containing a time |
12:30 |
None |
TimeWidget |
Timedelta
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Timedelta |
Field |
The difference between two dates or times |
|
None |
TextWidget |
Tuple
| Name |
Type |
Description |
Possible Values |
Default |
Possible widgets |
| Tuple |
Field |
A Field containing a value that implements the API of a conventional python tuple |
Tuple; 1,2,3 or 'a', 'b', 'c' |
None |
TextWidget |
URI
| Name |
Type |
Description |
Possible Values |
Default |
Widgets |
| URI |
Field |
A Field containing an absolute Uniform Resource Identifier |
Valid URI; http://cwarner.kernelcode.com/index |
None |
BytesWidget |
Christopher Warner is part genius, part idiot. This makes him well balanced. He's worked on numerous opensource projects with great people and has generally led an eventful and fulfilling life. He hopes to retire an old man in a rocking chair should he be so fortunate.
Plone Dexterity/Zope/Bluebream Fields Reference
Dexterity uses zope.schema.interfaces for its fields reference. Which means that technically, this documentation as of current is also relevant for Zope3/Bluebream developers explicitly. Also, please note the following documentation follows the beautifully structured organization (in table format) on Archetype fields for Plone by Mikko Ohtamaa located at the following url: http://plone.org/documentation/manual/developer-manual/archetypes/fields/fields-reference. It also includes some of the default apidoc that is clearly useful which is currently copyrighted to the Zope Corporation and subsequent contributors. As well as bits from Chapter 8 (Zope Schemas and Forms) from the Zope 3 Developer's Handbook written by Stephan Richter. Including obvious addition and compilation from myself, Christopher Warner. It follows zope.schema.interfaces version 3.6.0 as of today April 30, 2010. I should also note that I plan to follow where ever Dexterity and Plone lead so in the future the idea that this works with everything may, indeed, change.
Unfortunately, this documentation is required as the primary recommendation "For a complete listing of the schema/field API, see the API documentation tool at http://localhost:8080/++apidoc++ or see the zope.schema.interfaces module". Doesn't provide a good enough web reference for the budding Zope/Bluebream and/or Plone developer. The following url; http://docs.zope.org/zope3/Code/zope/schema/_field/ is a bit more helpful. However it's a pain to traverse or see ready made examples. So, I need a decent formatted reference that I can readily refer to in printed format for myself. The below will be a WIP (Work-In-Progress) until it meets my needs, so if you see an error or want to provide an example please don't hesitate. Summarily, the reader should expect a corresponding widget reference in the near future. Last but not least, the following has also been provided to you by the Institute for the Study of the Ancient World @ New York University since I am here at work right now.
These attributes are common to nearly all fields. Field-specific attributes follow, and are listed by field. Particular fields have different defaults, types and some other specialized attributes.
Common Field Attributes
The copy of the Field will have the 'context' attribute set to 'object'. This way a Field can implement more complex checks involving the object's location/environment.
Many fields don't need to be bound. Only fields that condition validation or properties on an object containing the field need to be bound
ASCII
ASCII Schema example code
from zope import schemafrom zope import interfaceclass Demo (interface.Interface):"ASCII Field declaration"ascii_demo = schema.ASCII(title = u'ASCII FIELD',description = u'An Ascii Field',)ASCIIWidget example
ASCIILine
ASCIILine Schema example code
from zope import schemafrom zope import interfaceclass Demo (interface.Interface):"ASCIILine Field declaration"asciiline_demo = schema.ASCIILine(title = u'ASCIILine FIELD',description = u'An Asciiline Field',)ASCIILineWidget example
Bool
Bytes
BytesLine
Choice
Date
Datetime
Decimal
Dict
DottedName
Float
FrozenSet
Int
Id
Len
MinMax
MinMaxLen
Object
Password
Set
SourceText
Text
TextLine
Time
Timedelta
Tuple
URI
Related Posts:
About Christopher Warner
Christopher Warner is part genius, part idiot. This makes him well balanced. He's worked on numerous opensource projects with great people and has generally led an eventful and fulfilling life. He hopes to retire an old man in a rocking chair should he be so fortunate.