- Timestamp:
- 10/02/09 14:30:48 (3 years ago)
- Location:
- elixir/branches/field_inherits_from_column/elixir
- Files:
-
- 2 modified
-
fields.py (modified) (6 diffs)
-
properties.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/branches/field_inherits_from_column/elixir/fields.py
r484 r494 116 116 117 117 118 class Field( Property):118 class Field(Column, Property): 119 119 ''' 120 120 Represents the definition of a 'field' on an entity. … … 122 122 This class represents a column on the table where the entity is stored. 123 123 ''' 124 124 #FIXME: collision between prop.name & col.name 125 125 def __init__(self, type, *args, **kwargs): 126 super(Field, self).__init__()126 Property.__init__(self) 127 127 128 128 self.colname = kwargs.pop('colname', None) … … 134 134 self.primary_key = kwargs.get('primary_key', False) 135 135 136 self.column = None136 Column.__init__(self, type, *args, **kwargs) 137 137 self.property = None 138 138 … … 141 141 142 142 def attach(self, entity, name): 143 if self.key is None: 144 self.key = name 145 if self.name is None: 146 self.name = name 147 143 148 # If no colname was defined (through the 'colname' kwarg), set 144 149 # it to the name of the attr. … … 155 160 self.create_col() 156 161 162 @property 163 def column(self): 164 return self 165 157 166 def create_col(self): 158 self.column = Column(self.colname, self.type, 159 *self.args, **self.kwargs) 160 self.add_table_column(self.column) 167 self.add_table_column(self) 161 168 162 169 def create_properties(self): … … 165 172 if isinstance(self.deferred, basestring): 166 173 group = self.deferred 167 self.property = deferred(self .column, group=group)174 self.property = deferred(self, group=group) 168 175 elif self.name != self.colname: 169 176 # if the property name is different from the column name, we need 170 177 # to add an explicit property (otherwise nothing is needed as it's 171 178 # done automatically by SA) 172 self.property = self .column179 self.property = self 173 180 174 181 if self.property is not None: -
elixir/branches/field_inherits_from_column/elixir/properties.py
r484 r494 105 105 return instance 106 106 107 _global_counter = 0 107 108 108 109 class Property(EntityBuilder): … … 110 111 Abstract base class for all properties of an Entity. 111 112 ''' 112 __metaclass__ = CounterMeta113 # __metaclass__ = CounterMeta 113 114 114 115 def __init__(self, *args, **kwargs): 116 global _global_counter 115 117 self.entity = None 116 118 self.name = None 119 self._counter = _global_counter 120 _global_counter += 1 117 121 118 122 def attach(self, entity, name):
