[breaking] domain description is defined in a dict, not in "__name__", "__id__", "__routers__" ...

This commit is contained in:
Maxime Alves LIRMM 2022-10-13 12:13:37 +02:00
parent fd682ba0e0
commit 7723acb812
4 changed files with 19 additions and 17 deletions

View File

@ -3,6 +3,7 @@
## 0.6.22
- IMPORTANT : Fix bug introduced with 0.6.20 (fix arguments handling)
- BREAKING : A domain should now include it's meta datas in a "domain" dictionary located in the __init__.py file of the domain's root. Consider looking in 'tests/dummy_domain/__init__.py'
- Add *html* return type as default argument ret_type
- Add *txt* return type
- Log unhandled exceptions

View File

@ -38,16 +38,15 @@ class HalfDomain(Starlette):
self.app = app
self.m_domain = importlib.import_module(domain) if module is None else module
self.name = getattr(self.m_domain, '__name__', domain)
self.id = getattr(self.m_domain, '__id__')
self.version = getattr(self.m_domain, '__version__', '0.0.0')
# TODO: Check if given domain halfapi_version matches with __version__
self.halfapi_version = getattr(self.m_domain, '__halfapi_version__', __version__)
self.deps = getattr(self.m_domain, '__deps__', tuple())
d_domain = getattr(self.m_domain, 'domain', domain)
self.name = d_domain['name']
self.id = d_domain['id']
self.version = d_domain['version']
self.halfapi_version = d_domain.get('halfapi_version', __version__)
self.deps = d_domain.get('deps', tuple())
if not router:
self.router = getattr(domain, '__router__', '.routers')
self.router = d_domain.get('routers', '.routers')
else:
self.router = router

View File

@ -1,12 +1,12 @@
from halfapi import __version__ as halfapi_version
__name__ = 'dummy_domain'
__version__ = '0.0.0'
__patch_release__ = '0.0.0'
__routers__ = '.routers'
__id__ = '8b88e60a625369235b36c2d6d70756a0c02c1c7fb169fcee6dc820bcf9723f5a'
domain = {
'name': 'dummy_domain',
'version': '0.0.0',
'id': '8b88e60a625369235b36c2d6d70756a0c02c1c7fb169fcee6dc820bcf9723f5a',
'deps': (
('halfapi', '=={}'.format(halfapi_version)),
)
}
__deps__ = (
('halfapi', '=={}'.format(halfapi_version)),
)

View File

@ -3,7 +3,9 @@ from halfapi.testing.test_domain import TestDomain
from pprint import pprint
class TestDummyDomain(TestDomain):
from .dummy_domain import __name__, __routers__
from .dummy_domain import domain
__name__ = domain.get('name')
__routers__ = domain.get('routers')
DOMAIN = __name__
CONFIG = {'test': True}