Changing get_user_record into a normal object method.
[sfa.git] / sfa / iotlab / iotlabdriver.py
index a5703d4..ec90293 100644 (file)
@@ -3,7 +3,6 @@ Implements what a driver should provide for SFA to work.
 """
 from sfa.util.faults import SliverDoesNotExist, UnknownSfaType
 from sfa.util.sfalogging import logger
-from sfa.storage.alchemy import dbsession
 from sfa.storage.model import RegRecord
 
 from sfa.managers.driver import Driver
@@ -28,7 +27,7 @@ class IotlabDriver(Driver):
     .. seealso::: Driver class
 
     """
-    def __init__(self, config):
+    def __init__(self, api):
         """
 
         Sets the iotlab SFA config parameters,
@@ -38,9 +37,10 @@ class IotlabDriver(Driver):
         :type config: Config object
 
         """
-        Driver.__init__(self, config)
-        self.config = config
-        self.testbed_shell = IotlabShell(config)
+        Driver.__init__(self, api)
+        self.api=api
+        config = api.config
+        self.testbed_shell = IotlabShell(api)
         self.cache = None
 
     def augment_records_with_testbed_info(self, record_list):
@@ -297,8 +297,7 @@ class IotlabDriver(Driver):
                          % (resources, res))
             return result
 
-    @staticmethod
-    def get_user_record(hrn):
+    def get_user_record(self, hrn):
         """
 
         Returns the user record based on the hrn from the SFA DB .
@@ -309,7 +308,11 @@ class IotlabDriver(Driver):
         :rtype: RegUser
 
         """
-        return dbsession.query(RegRecord).filter_by(hrn=hrn).first()
+        # xxx this method should not be static
+        from sfa.storage.alchemy import global_dbsession
+        return global_dbsession.query(RegRecord).filter_by(hrn=hrn).first()
+        # code should read instead (if this method was not static, that is)
+        #return self.api.dbsession().query(RegRecord).filter_by(hrn=hrn).first()
 
     def testbed_name(self):
         """