core (memory/storage): backend storage is now based on SQLAlchemy

This commit is contained in:
Goffi 2021-06-03 15:20:47 +02:00
commit a5f225e1ea
3 changed files with 1335 additions and 1784 deletions

21
sat/core/core_types.py Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python3
# Libervia types
# Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class SatXMPPEntity:
pass

View file

@ -58,6 +58,7 @@ except ImportError:
log = getLogger(__name__)
class SAT(service.Service):
def _init(self):
# we don't use __init__ to avoid doule initialisation with twistd
# this _init is called in startService
@ -175,8 +176,7 @@ class SAT(service.Service):
self.bridge.register_method("imageResize", self._imageResize)
self.bridge.register_method("imageGeneratePreview", self._imageGeneratePreview)
self.bridge.register_method("imageConvert", self._imageConvert)
self.memory.initialized.addCallback(lambda __: defer.ensureDeferred(self._postMemoryInit()))
defer.ensureDeferred(self._postInit())
@property
def version(self):
@ -206,8 +206,8 @@ class SAT(service.Service):
def bridge_name(self):
return os.path.splitext(os.path.basename(self.bridge.__file__))[0]
async def _postMemoryInit(self):
"""Method called after memory initialization is done"""
async def _postInit(self):
await self.memory.initialise()
self.common_cache = cache.Cache(self, None)
log.info(_("Memory initialised"))
try:

View file

@ -42,6 +42,7 @@ from wokkel import component
from wokkel import delay
from sat.core.log import getLogger
from sat.core import exceptions
from sat.core import core_types
from sat.memory import encryption
from sat.memory import persistent
from sat.tools import xml_tools
@ -83,7 +84,7 @@ class ClientPluginWrapper:
return partial(getattr(self.plugin, attr), self.client)
class SatXMPPEntity:
class SatXMPPEntity(core_types.SatXMPPEntity):
"""Common code for Client and Component"""
# profile is added there when startConnection begins and removed when it is finished
profiles_connecting = set()