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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---