Changeset 303 for elixir/trunk/elixir/properties.py
- Timestamp:
- 02/07/08 15:57:55 (4 years ago)
- Files:
-
- 1 modified
-
elixir/trunk/elixir/properties.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/elixir/properties.py
r269 r303 4 4 properties such as fields and relationships (for those, please consult the 5 5 corresponding modules), but also provides some more specialized properties, 6 such as `ColumnProperty` . It also provides the GenericProperty class which7 allows you to wrap any SQLAlchemy property, and its DSL-syntax equivalent:8 has_property_.6 such as `ColumnProperty` and `Synonym`. It also provides the GenericProperty 7 class which allows you to wrap any SQLAlchemy property, and its DSL-syntax 8 equivalent: has_property_. 9 9 10 10 `has_property` … … 32 32 33 33 from elixir.statements import PropertyStatement 34 from sqlalchemy.orm import column_property 34 from sqlalchemy.orm import column_property, synonym 35 35 36 36 __doc_all__ = ['EntityBuilder', 'Property', 'GenericProperty', … … 150 150 def evaluate_property(self, prop): 151 151 return prop 152 152 153 153 154 class ColumnProperty(GenericProperty): … … 179 180 return column_property(prop.label(self.name)) 180 181 182 183 class Synonym(GenericProperty): 184 ''' 185 This class represents a synonym property of another property (column, ...) 186 of an entity. As opposed to the `synonym` kwarg to the Field class (which 187 share the same goal), this class can be used to define a synonym of a 188 property defined in a parent class (of the current class). On the other 189 hand, it cannot define a synonym for the purpose of using a standard python 190 property in queries. See the Field class for details on that usage. 191 192 .. sourcecode:: python 193 194 class Person(Entity): 195 name = Field(String(30)) 196 primary_email = Field(String(100)) 197 email_address = Synonym('primary_email') 198 199 class User(Person): 200 user_name = Synonym('name') 201 password = Field(String(20)) 202 ''' 203 204 def evaluate_property(self, prop): 205 return synonym(prop) 206 181 207 #class Composite(GenericProperty): 182 208 # def __init__(self, prop):
