diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-08-28 17:10:43 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-08-28 17:10:43 +0100 |
commit | 32eb1dedd294831f2bafc79a24dae91eee319563 (patch) | |
tree | 34109c01156e3cbf140a50008a92d4dfc645da58 | |
parent | changelog (diff) | |
download | synapse-32eb1dedd294831f2bafc79a24dae91eee319563.tar.xz |
use abc.abstractproperty
This gives clearer messages when someone gets it wrong
-rw-r--r-- | synapse/server.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/synapse/server.py b/synapse/server.py index 802d679cde..938a05f9dc 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -19,6 +19,7 @@ # partial one for unit test mocking. # Imports required for the default HomeServer() implementation +import abc import logging from twisted.enterprise import adbapi @@ -110,6 +111,8 @@ class HomeServer(object): config (synapse.config.homeserver.HomeserverConfig): """ + __metaclass__ = abc.ABCMeta + DEPENDENCIES = [ 'http_client', 'db_pool', @@ -174,7 +177,7 @@ class HomeServer(object): # This is overridden in derived application classes # (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be # instantiated during setup() for future return by get_datastore() - DATASTORE_CLASS = None + DATASTORE_CLASS = abc.abstractproperty() def __init__(self, hostname, reactor=None, **kwargs): """ @@ -200,10 +203,6 @@ class HomeServer(object): def setup(self): logger.info("Setting up.") - if self.DATASTORE_CLASS is None: - raise RuntimeError("%s does not define a DATASTORE_CLASS" % ( - self.__class__.__name__, - )) with self.get_db_conn() as conn: self.datastore = self.DATASTORE_CLASS(conn, self) logger.info("Finished setting up.") |