summary refs log tree commit diff
path: root/synapse/storage/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-20 15:05:44 +0000
committerErik Johnston <erik@matrix.org>2015-03-20 15:05:44 +0000
commitfce01140057c54714b591aa327095dcee9936b4b (patch)
tree9bcf859cb130519b239facb480db6882cc6ded7a /synapse/storage/room.py
parentTidy up _simple_... methods (diff)
downloadsynapse-fce01140057c54714b591aa327095dcee9936b4b.tar.xz
Start removing Tables
Diffstat (limited to 'synapse/storage/room.py')
-rw-r--r--synapse/storage/room.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/synapse/storage/room.py b/synapse/storage/room.py
index 71bae15450..a16d321925 100644
--- a/synapse/storage/room.py
+++ b/synapse/storage/room.py
@@ -15,11 +15,9 @@
 
 from twisted.internet import defer
 
-from sqlite3 import IntegrityError
-
 from synapse.api.errors import StoreError
 
-from ._base import SQLBaseStore, Table
+from ._base import SQLBaseStore
 
 import collections
 import logging
@@ -27,8 +25,9 @@ import logging
 logger = logging.getLogger(__name__)
 
 
-OpsLevel = collections.namedtuple("OpsLevel", (
-    "ban_level", "kick_level", "redact_level")
+OpsLevel = collections.namedtuple(
+    "OpsLevel",
+    ("ban_level", "kick_level", "redact_level",)
 )
 
 
@@ -47,13 +46,14 @@ class RoomStore(SQLBaseStore):
             StoreError if the room could not be stored.
         """
         try:
-            yield self._simple_insert(RoomsTable.table_name, dict(
-                room_id=room_id,
-                creator=room_creator_user_id,
-                is_public=is_public
-            ))
-        except IntegrityError:
-            raise StoreError(409, "Room ID in use.")
+            yield self._simple_insert(
+                RoomsTable.table_name,
+                {
+                    "room_id": room_id,
+                    "creator": room_creator_user_id,
+                    "is_public": is_public,
+                }
+            )
         except Exception as e:
             logger.error("store_room with room_id=%s failed: %s", room_id, e)
             raise StoreError(500, "Problem creating room.")
@@ -66,9 +66,10 @@ class RoomStore(SQLBaseStore):
         Returns:
             A namedtuple containing the room information, or an empty list.
         """
-        query = RoomsTable.select_statement("room_id=?")
-        return self._execute(
-            "get_room", RoomsTable.decode_single_result, query, room_id,
+        return self._simple_select_one(
+            table=RoomsTable.table_name,
+            keyvalues={"room_id": room_id},
+            retcols=RoomsTable.fields,
         )
 
     @defer.inlineCallbacks
@@ -196,7 +197,7 @@ class RoomStore(SQLBaseStore):
         defer.returnValue((name, aliases))
 
 
-class RoomsTable(Table):
+class RoomsTable(object):
     table_name = "rooms"
 
     fields = [
@@ -204,5 +205,3 @@ class RoomsTable(Table):
         "is_public",
         "creator"
     ]
-
-    EntryType = collections.namedtuple("RoomEntry", fields)