Package Camelot :: Package camelot :: Package types :: Class Enumeration
[frames] | no frames]

Class Enumeration

source code


The enumeration field stores integers in the database, but represents them as strings. This allows efficient storage and querying while preserving readable code.

Typical use of this field would be a status field.

Enumeration fields are visualized as a combo box, where the labels in the combo box are the capitalized strings:

class Movie(Entity):
  title = Field(Unicode(60), required=True)
  state = Field(camelot.types.Enumeration([(1,'planned'), (2,'recording'), (3,'finished'), (4,'canceled')]),
                                          index=True, required=True, default='planning')
../_static/editors/ChoicesEditor_editable.png
Nested Classes
  impl
A type for int integers.
Instance Methods
 
__init__(self, choices=[], **kwargs)
@param param: choices is a list of tuples. each tuple contains an integer and its associated string. eg. : choices = [(1,'draft'), (2,'approved')]
source code
 
bind_processor(self, dialect)
Defines a bind parameter processing function.
source code
 
result_processor(self, dialect)
Defines a result-column processing function.
source code

Inherited from sqlalchemy.types.TypeDecorator: __getattr__, compare_values, copy, copy_value, dialect_impl, get_col_spec, get_dbapi_type, is_mutable, load_dialect_impl, process_bind_param, process_result_value

Inherited from sqlalchemy.types.AbstractType: __repr__, adapt_operator

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, choices=[], **kwargs)
(Constructor)

source code 
@param param: choices is a list of tuples. each tuple contains an integer and its associated string. eg. : choices = [(1,'draft'), (2,'approved')]
Overrides: object.__init__

bind_processor(self, dialect)

source code 
Defines a bind parameter processing function.
Overrides: sqlalchemy.types.AbstractType.bind_processor
(inherited documentation)

result_processor(self, dialect)

source code 
Defines a result-column processing function.
Overrides: sqlalchemy.types.AbstractType.result_processor
(inherited documentation)