server/sources/pyrorql.py
changeset 6957 ffda12be2e9f
parent 6946 e350771c23a3
child 6958 861251f125cf
--- a/server/sources/pyrorql.py	Wed Feb 09 18:06:13 2011 +0100
+++ b/server/sources/pyrorql.py	Wed Feb 09 18:06:17 2011 +0100
@@ -168,9 +168,9 @@
         finally:
             session.close()
 
-    def init(self, activated, session=None):
+    def init(self, activated, source_entity):
         """method called by the repository once ready to handle request"""
-        self.load_mapping(session)
+        self.load_mapping(source_entity._cw)
         if activated:
             interval = self.config['synchronization-interval']
             self.repo.looping_task(interval, self.synchronize)
@@ -184,19 +184,7 @@
         self.cross_relations = set()
         assert self.eid is not None
         self._schemacfg_idx = {}
-        if session is None:
-            _session = self.repo.internal_session()
-        else:
-            _session = session
-        try:
-            for schemacfg in _session.execute(
-                'Any CFG,CFGO,SN,S WHERE '
-                'CFG options CFGO, CFG cw_schema S, S name SN, '
-                'CFG cw_for_source X, X eid %(x)s', {'x': self.eid}).entities():
-                self.add_schema_config(schemacfg)
-        finally:
-            if session is None:
-                _session.close()
+        self._load_mapping(session)
 
     etype_options = set(('write',))
     rtype_options = set(('maycross', 'dontcross', 'write',))