Class: ColumnProperty
A specialized form of the GenericProperty to generate SQLAlchemy column_property's.
It takes a function (often given as an anonymous lambda) as its first argument. Other arguments and keyword arguments are forwarded to the column_property construct. That first-argument function must accept exactly one argument and must return the desired (scalar-returning) SQLAlchemy ClauseElement.
The function will be called whenever the entity table is completely defined, and will be given the .c attribute of the table of the entity as argument (as a way to access the entity columns). The ColumnProperty will first wrap your ClauseElement in an "empty" label (ie it will be labelled automatically during queries), then wrap that in a column_property.
class OrderLine(Entity): quantity = Field(Float) unit_price = Field(Numeric) price = ColumnProperty(lambda c: c.quantity * c.unit_price, deferred=True)
Please look at the corresponding SQLAlchemy documentation for details.
Methods
add_mapper_extension (self, ext)
add_mapper_property (self, name, prop)
add_table_column (self, column)
helper methods
after_mapper (self)
after_table (self)
attach (self, entity, name)
Attach this property to its entity, using 'name' as name.
Properties will be attached in the order they were declared.
before_mapper (self)
before_table (self)
create_non_pk_cols (self)
create_pk_cols (self)
create_properties (self)
create_tables (self)
Subclasses may override this method to create tables.
