class AttributeImpl(object):
"""internal implementation for instrumented attributes."""
- def __init__(self, class_, key, callable_, class_manager, trackparent=False, extension=None, compare_function=None, **kwargs):
+ def __init__(self, class_, key, callable_, class_manager, trackparent=False, extension=None, compare_function=None, active_history=False, **kwargs):
"""Construct an AttributeImpl.
\class_
self.callable_ = callable_
self.class_manager = class_manager
self.trackparent = trackparent
+ self.active_history = active_history
if compare_function is None:
self.is_equal = operator.eq
else:
uses_objects = False
def delete(self, state):
- state.modified_event(self, False, state.dict.get(self.key, NO_VALUE))
# TODO: catch key errors, convert to attributeerror?
- if self.extensions:
+ if self.active_history or self.extensions:
old = self.get(state)
+ else:
+ old = state.dict.get(self.key, NO_VALUE)
+
+ state.modified_event(self, False, old)
+
+ if self.extensions:
del state.dict[self.key]
self.fire_remove_event(state, old, None)
else:
if initiator is self:
return
- state.modified_event(self, False, state.dict.get(self.key, NO_VALUE))
+ if self.active_history or self.extensions:
+ old = self.get(state)
+ else:
+ old = state.dict.get(self.key, NO_VALUE)
+
+ state.modified_event(self, False, old)
if self.extensions:
- old = self.get(state)
state.dict[self.key] = value
self.fire_replace_event(state, value, old, initiator)
else:
class DefaultColumnLoader(LoaderStrategy):
- def _register_attribute(self, compare_function, copy_function, mutable_scalars, comparator_factory, callable_=None, proxy_property=None):
+ def _register_attribute(self, compare_function, copy_function, mutable_scalars, comparator_factory, callable_=None, proxy_property=None, active_history=False):
self.logger.info("%s register managed attribute" % self)
for mapper in self.parent.polymorphic_iterator():
comparator=comparator_factory(self.parent_property, mapper),
parententity=mapper,
callable_=callable_,
- proxy_property=proxy_property
+ proxy_property=proxy_property,
+ active_history=active_history
)
DefaultColumnLoader.logger = log.class_logger(DefaultColumnLoader)
def init_class_attribute(self):
self.is_class_level = True
coltype = self.columns[0].type
+ active_history = self.columns[0].primary_key # TODO: check all columns ? check for foreign Key as well?
self._register_attribute(
coltype.compare_values,
coltype.copy_value,
self.columns[0].type.is_mutable(),
- self.parent_property.comparator_factory
+ self.parent_property.comparator_factory,
+ active_history = active_history
+
)
def create_row_processor(self, selectcontext, path, mapper, row, adapter):