Changeset 206
- Timestamp:
- 09/24/07 00:07:13 (6 years ago)
- Location:
- elixir/trunk
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
elixir/ext/versioned.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/CHANGES
r205 r206 1 1 0.4.0 2 - Fixed bug in versioning that could cause repeat inserts of duplicates into 3 the version history. This was due to SA flagging items for update when they 4 weren't actually going to be updated. 2 5 - Implemented ondelete/onupdate options for use with has_and_belongs_to_many 3 6 to apply on delete clauses to foreign key constraints on the m2m table. -
elixir/trunk/elixir/ext/versioned.py
r202 r206 79 79 instance.version = 1 80 80 instance.timestamp = datetime.now() 81 colvalues = dict([(key, getattr(instance, key)) for key in instance.c.keys()]) 82 instance.__class__.__history_table__.insert().execute(colvalues) 81 83 return EXT_PASS 82 84 83 85 def before_update(self, mapper, connection, instance): 84 values = instance.table.select(get_entity_where(instance)).execute().fetchone() 85 colvalues = dict(values.items()) 86 # In SQLAlchemy 0.3.X, and possibly 0.4 (unknown), objects can 87 # sometimes be implicated to be saved when in fact they haven't been 88 # updated. If we've already inserted this version, we don't need to 89 # insert it again. 90 values = instance.__class__.__history_table__.select(get_entity_where(instance), 91 order_by=[desc(instance.c.timestamp)]).execute().fetchone() 92 if values and instance.version == values['version']: 93 return EXT_PASS 94 95 colvalues = dict([(key, getattr(instance, key)) for key in instance.c.keys()]) 96 86 97 instance.__class__.__history_table__.insert().execute(colvalues) 87 98 instance.version += 1 … … 148 159 # if the passed in timestamp is older than our current version's 149 160 # time stamp, then the most recent version is our current version 150 if self.timestamp < dt: 161 if self.timestamp < dt: 151 162 return self 152 163
