Show
Ignore:
Timestamp:
03/05/07 21:32:53 (6 years ago)
Author:
ged
Message:

- Added support for the "version_id_col" option on entities. This option adds

a column to the table which will be used to prevent concurrent modifications
on any row of the entity's table (i.e. it will raise an error if it happens).

- Using invalid options on entities will now raise an exception

Files:
1 modified

Legend:

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

    r82 r83  
    2525DEFAULT_AUTO_PRIMARYKEY_NAME = "id" 
    2626DEFAULT_AUTO_PRIMARYKEY_TYPE = Integer 
    27  
     27DEFAULT_VERSION_ID_COL = "row_version" 
    2828 
    2929class EntityDescriptor(object): 
     
    7070 
    7171        for option in ('inheritance',  
    72                        'autoload', 'shortnames', 'auto_primarykey'): 
     72                       'autoload', 'shortnames', 'auto_primarykey', 
     73                       'version_id_col'): 
    7374            setattr(self, option, options_defaults[option]) 
    7475 
     
    141142            kwargs['order_by'] = self.translate_order_by(self.order_by) 
    142143         
     144        if self.version_id_col: 
     145            kwargs['version_id_col'] = self.fields[self.version_id_col].column 
     146 
    143147        if self.parent: 
    144148            if self.inheritance == 'single': 
     
    192196#                for field in self.fields.itervalues(): 
    193197#                    self.add_field(field) 
     198 
     199        if self.version_id_col: 
     200            if not isinstance(self.version_id_col, basestring): 
     201                self.version_id_col = DEFAULT_VERSION_ID_COL 
     202            self.add_field(Field(Integer, colname=self.version_id_col)) 
    194203 
    195204        if not self.autoload: