forked from MirrorHub/synapse
use abc.abstractproperty
This gives clearer messages when someone gets it wrong
This commit is contained in:
parent
71990b3cae
commit
32eb1dedd2
1 changed files with 4 additions and 5 deletions
|
@ -19,6 +19,7 @@
|
||||||
# partial one for unit test mocking.
|
# partial one for unit test mocking.
|
||||||
|
|
||||||
# Imports required for the default HomeServer() implementation
|
# Imports required for the default HomeServer() implementation
|
||||||
|
import abc
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from twisted.enterprise import adbapi
|
from twisted.enterprise import adbapi
|
||||||
|
@ -110,6 +111,8 @@ class HomeServer(object):
|
||||||
config (synapse.config.homeserver.HomeserverConfig):
|
config (synapse.config.homeserver.HomeserverConfig):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__metaclass__ = abc.ABCMeta
|
||||||
|
|
||||||
DEPENDENCIES = [
|
DEPENDENCIES = [
|
||||||
'http_client',
|
'http_client',
|
||||||
'db_pool',
|
'db_pool',
|
||||||
|
@ -174,7 +177,7 @@ class HomeServer(object):
|
||||||
# This is overridden in derived application classes
|
# This is overridden in derived application classes
|
||||||
# (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be
|
# (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be
|
||||||
# instantiated during setup() for future return by get_datastore()
|
# instantiated during setup() for future return by get_datastore()
|
||||||
DATASTORE_CLASS = None
|
DATASTORE_CLASS = abc.abstractproperty()
|
||||||
|
|
||||||
def __init__(self, hostname, reactor=None, **kwargs):
|
def __init__(self, hostname, reactor=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -200,10 +203,6 @@ class HomeServer(object):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
logger.info("Setting up.")
|
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:
|
with self.get_db_conn() as conn:
|
||||||
self.datastore = self.DATASTORE_CLASS(conn, self)
|
self.datastore = self.DATASTORE_CLASS(conn, self)
|
||||||
logger.info("Finished setting up.")
|
logger.info("Finished setting up.")
|
||||||
|
|
Loading…
Reference in a new issue