server/sources/storages.py
changeset 5397 cdbf823450aa
parent 5396 78d92a47a4e5
child 5398 b9e1abe1bdfe
--- a/server/sources/storages.py	Fri Apr 23 17:54:34 2010 +0200
+++ b/server/sources/storages.py	Fri Apr 23 17:55:46 2010 +0200
@@ -50,6 +50,9 @@
     def entity_deleted(self, entity, attr):
         """an entity using this storage for attr has been deleted"""
         raise NotImplementedError()
+    def migrate_entity(self, entity, attribute):
+        """migrate an entity attribute to the storage"""
+        raise NotImplementedError()
 
 # TODO
 # * make it configurable without code
@@ -150,6 +153,16 @@
         return sysource._process_value(rawvalue, cu.description[0],
                                        binarywrap=str)
 
+    def migrate_entity(self, entity, attribute):
+        """migrate an entity attribute to the storage"""
+        entity.edited_attributes = set()
+        self.entity_added(entity, attribute)
+        session = entity._cw
+        source = session.repo.system_source
+        attrs = source.preprocess_entity(entity)
+        sql = source.sqlgen.update('cw_' + entity.__regid__, attrs,
+                                   ['cw_eid'])
+        source.doexec(session, sql, attrs)
 
 
 class AddFileOp(hook.Operation):