summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2017-11-02 10:41:25 +0000
committerGitHub <noreply@github.com>2017-11-02 10:41:25 +0000
commit04897c9dc1910bb2ad3a26d03b4eef63b57775a0 (patch)
treea5d50eda7920c27d66664a1263c54c70328a4162 /synapse/handlers
parentMerge pull request #2620 from matrix-org/rav/auth_non_password (diff)
parentLet auth providers get to the database (diff)
downloadsynapse-04897c9dc1910bb2ad3a26d03b4eef63b57775a0.tar.xz
Merge pull request #2622 from matrix-org/rav/db_access_for_auth_providers
Let auth providers get to the database
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/auth.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 9799461d26..0e5be98daa 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -826,6 +826,7 @@ class _AccountHandler(object):
         self.hs = hs
 
         self._check_user_exists = check_user_exists
+        self._store = hs.get_datastore()
 
     def get_qualified_user_id(self, username):
         """Qualify a user id, if necessary
@@ -863,3 +864,18 @@ class _AccountHandler(object):
         """
         reg = self.hs.get_handlers().registration_handler
         return reg.register(localpart=localpart)
+
+    def run_db_interaction(self, desc, func, *args, **kwargs):
+        """Run a function with a database connection
+
+        Args:
+            desc (str): description for the transaction, for metrics etc
+            func (func): function to be run. Passed a database cursor object
+                as well as *args and **kwargs
+            *args: positional args to be passed to func
+            **kwargs: named args to be passed to func
+
+        Returns:
+            Deferred[object]: result of func
+        """
+        return self._store.runInteraction(desc, func, *args, **kwargs)