Show
Ignore:
Timestamp:
06/19/08 15:35:21 (5 years ago)
Author:
ged
Message:

removed trailing spaces

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/properties.py

    r327 r347  
    11''' 
    22This module provides support for defining properties on your entities. It both 
    3 provides, the `Property` class which acts as a building block for common  
    4 properties such as fields and relationships (for those, please consult the  
    5 corresponding modules), but also provides some more specialized properties,  
    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  
     3provides, the `Property` class which acts as a building block for common 
     4properties such as fields and relationships (for those, please consult the 
     5corresponding modules), but also provides some more specialized properties, 
     6such as `ColumnProperty` and `Synonym`. It also provides the GenericProperty 
     7class which allows you to wrap any SQLAlchemy property, and its DSL-syntax 
    88equivalent: has_property_. 
    99 
    1010`has_property` 
    1111-------------- 
    12 The ``has_property`` statement allows you to define properties which rely on  
     12The ``has_property`` statement allows you to define properties which rely on 
    1313their entity's table (and columns) being defined before they can be declared 
    1414themselves. The `has_property` statement takes two arguments: first the name of 
     
    1616lambda) taking one argument and returning the desired SQLAlchemy property. That 
    1717function will be called whenever the entity table is completely defined, and 
    18 will be given the .c attribute of the entity as argument (as a way to access  
     18will be given the .c attribute of the entity as argument (as a way to access 
    1919the entity columns). 
    2020 
     
    2626        has_field('quantity', Float) 
    2727        has_field('unit_price', Float) 
    28         has_property('price',  
     28        has_property('price', 
    2929                     lambda c: column_property( 
    3030                         (c.quantity * c.unit_price).label('price'))) 
     
    3434from sqlalchemy.orm import column_property, synonym 
    3535 
    36 __doc_all__ = ['EntityBuilder', 'Property', 'GenericProperty',  
     36__doc_all__ = ['EntityBuilder', 'Property', 'GenericProperty', 
    3737               'ColumnProperty'] 
    3838 
    3939class EntityBuilder(object): 
    4040    ''' 
    41     Abstract base class for all entity builders. An Entity builder is a class  
    42     of objects which can be added to an Entity (usually by using special  
     41    Abstract base class for all entity builders. An Entity builder is a class 
     42    of objects which can be added to an Entity (usually by using special 
    4343    properties or statements) to "build" that entity. Building an entity, 
    4444    meaning to add columns to its "main" table, create other tables, add 
     
    6666 
    6767    def create_properties(self): 
    68         pass     
     68        pass 
    6969 
    7070    def before_mapper(self): 
    71         pass     
     71        pass 
    7272 
    7373    def after_mapper(self): 
    74         pass     
     74        pass 
    7575 
    7676    def finalize(self): 
    77         pass     
     77        pass 
    7878 
    7979 
     
    9898    ''' 
    9999    __metaclass__ = CounterMeta 
    100      
     100 
    101101    def __init__(self, *args, **kwargs): 
    102102        self.entity = None 
     
    135135                             (c.quantity * c.unit_price).label('price'))) 
    136136    ''' 
    137      
     137 
    138138    def __init__(self, prop): 
    139139        super(GenericProperty, self).__init__() 
     
    154154class ColumnProperty(GenericProperty): 
    155155    ''' 
    156     A specialized form of the GenericProperty to generate SQLAlchemy  
    157     ``column_property``'s.  
    158      
    159     It takes a single argument, which is a function (often  
    160     given as an anonymous lambda) taking one argument and returning the  
     156    A specialized form of the GenericProperty to generate SQLAlchemy 
     157    ``column_property``'s. 
     158 
     159    It takes a single argument, which is a function (often 
     160    given as an anonymous lambda) taking one argument and returning the 
    161161    desired (scalar-returning) SQLAlchemy ClauseElement. That function will be 
    162     called whenever the entity table is completely defined, and will be given  
    163     the .c attribute of the entity as argument (as a way to access the entity  
     162    called whenever the entity table is completely defined, and will be given 
     163    the .c attribute of the entity as argument (as a way to access the entity 
    164164    columns). The ColumnProperty will first wrap your ClauseElement in a label 
    165165    with the same name as the property, then wrap that in a column_property. 
     
    172172            price = ColumnProperty(lambda c: c.quantity * c.unit_price) 
    173173 
    174     Please look at the `corresponding SQLAlchemy  
     174    Please look at the `corresponding SQLAlchemy 
    175175    documentation <http://www.sqlalchemy.org/docs/04/mappers.html 
    176176    #advdatamapping_mapper_expressions>`_ for details. 
     
    184184    ''' 
    185185    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  
     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 
    188188    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  
     189    hand, it cannot define a synonym for the purpose of using a standard python 
    190190    property in queries. See the Field class for details on that usage. 
    191191