you can add event handlers to attributes using @validates:
http://www.sqlalchemy.org/docs/05/mappers.html?highlight=validates#simple-validators or the more longhand AttributeExtension: http://www.sqlalchemy.org/docs/05/reference/orm/interfaces.html?highlight=attributeextension#sqlalchemy.orm.interfaces.AttributeExtension jarrod.ches...@gmail.com wrote: > > class OrmRecord(object): > > def _get_column_value(self, name): > # return self.__dict__[name] > return getattr(self, name) > > def _set_column_value(self, name, value): > val = setattr(self, name, value) > self._notify_change_functions() > > # Return result just because > return val > > def add_change_function(self, instance, function): > """ Add Change Function > > Add a function to this record that will be modified > when this record is changed > This function will be called and passed the record it > wants to be notified about > > instance > The instance of the object to be called back > > function > The function to be called and passed the instance > > > """ > > try: > self._change_functions > except AttributeError: > self._change_functions = weakref.WeakKeyDictionary > () > > self._change_functions[instance] = function > > def _notify_change_functions(self): > try: > self._change_functions > except AttributeError: > return > > for instance in self._change_functions: > self._change_functions[instance](self) > > > > self._OrmRecord = OrmRecord > > print 'Mapped ' + self.schema_table_name + '\n\t' + str > (self._OrmRecord) + '\n\t' + str(metadata.tables > [self.schema_table_name]) > self._mapper = mapper(self._OrmRecord, self._metadata_table) > > > > This is the code i put together > I set the value of the orm_record using the setter and getter > functions above. > > Anyone know of a more sqlalchemy way of doing it? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---