unset_attribute_storage, for testing purpose at least
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 08 Feb 2010 22:41:07 +0100
changeset 4512 e7ac20bf3629
parent 4511 270a75f6e33f
child 4513 8abf464d2ffe
child 4525 956a0630abc8
unset_attribute_storage, for testing purpose at least
server/sources/native.py
server/sources/storages.py
--- a/server/sources/native.py	Mon Feb 08 21:29:59 2010 +0100
+++ b/server/sources/native.py	Mon Feb 08 22:41:07 2010 +0100
@@ -231,6 +231,9 @@
     def map_attribute(self, etype, attr, cb):
         self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb
 
+    def unmap_attribute(self, etype, attr):
+        self._rql_sqlgen.attr_map.pop('%s.%s' % (etype, attr), None)
+
     # ISource interface #######################################################
 
     def compile_rql(self, rql, sols):
--- a/server/sources/storages.py	Mon Feb 08 21:29:59 2010 +0100
+++ b/server/sources/storages.py	Mon Feb 08 22:41:07 2010 +0100
@@ -10,6 +10,10 @@
     ETYPE_ATTR_STORAGE.setdefault(etype, {})[attr] = storage
     repo.system_source.map_attribute(etype, attr, storage.sqlgen_callback)
 
+def unset_attribute_storage(repo, etype, attr):
+    ETYPE_ATTR_STORAGE.setdefault(etype, {}).pop(attr, None)
+    repo.system_source.unmap_attribute(etype, attr)
+
 
 class Storage(object):
     """abstract storage"""