mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Webserver stuff is complete!
This commit is contained in:
parent
884b44302d
commit
c2d9f747fa
3 changed files with 26 additions and 1 deletions
|
@ -156,9 +156,17 @@ def run(telegram: typing.Optional[bool],
|
||||||
|
|
||||||
webserver_process: typing.Optional[multiprocessing.Process] = None
|
webserver_process: typing.Optional[multiprocessing.Process] = None
|
||||||
if interfaces["webserver"]:
|
if interfaces["webserver"]:
|
||||||
|
# Common tables are always included
|
||||||
|
constellation_tables = set(r.packs.common.available_tables)
|
||||||
|
# Find the required tables
|
||||||
|
for star in [*enabled_page_stars, *enabled_exception_stars]:
|
||||||
|
constellation_tables = constellation_tables.union(star.tables)
|
||||||
|
# Create the Constellation
|
||||||
constellation = r.web.Constellation(page_stars=enabled_page_stars,
|
constellation = r.web.Constellation(page_stars=enabled_page_stars,
|
||||||
exc_stars=enabled_exception_stars,
|
exc_stars=enabled_exception_stars,
|
||||||
secrets_name=secrets_name)
|
secrets_name=secrets_name,
|
||||||
|
database_uri=database,
|
||||||
|
tables=constellation_tables)
|
||||||
webserver_process = multiprocessing.Process(name="Constellation Webserver",
|
webserver_process = multiprocessing.Process(name="Constellation Webserver",
|
||||||
target=constellation.run_blocking,
|
target=constellation.run_blocking,
|
||||||
args=(verbose,),
|
args=(verbose,),
|
||||||
|
|
|
@ -14,6 +14,8 @@ log = logging.getLogger(__name__)
|
||||||
class Constellation:
|
class Constellation:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
secrets_name: str,
|
secrets_name: str,
|
||||||
|
database_uri: str,
|
||||||
|
tables: set,
|
||||||
page_stars: typing.List[typing.Type[PageStar]] = None,
|
page_stars: typing.List[typing.Type[PageStar]] = None,
|
||||||
exc_stars: typing.List[typing.Type[ExceptionStar]] = None,
|
exc_stars: typing.List[typing.Type[ExceptionStar]] = None,
|
||||||
*,
|
*,
|
||||||
|
@ -29,6 +31,9 @@ class Constellation:
|
||||||
log.info("Creating starlette app...")
|
log.info("Creating starlette app...")
|
||||||
self.starlette = Starlette(debug=debug)
|
self.starlette = Starlette(debug=debug)
|
||||||
|
|
||||||
|
log.info(f"Creating alchemy with tables: {' '.join([table.__name__ for table in tables])}")
|
||||||
|
self.alchemy: royalnet.database.Alchemy = royalnet.database.Alchemy(database_uri=database_uri, tables=tables)
|
||||||
|
|
||||||
log.info("Registering page_stars...")
|
log.info("Registering page_stars...")
|
||||||
for SelectedPageStar in page_stars:
|
for SelectedPageStar in page_stars:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -14,6 +14,18 @@ class Star:
|
||||||
async def page(self, request: Request, **kwargs) -> Response:
|
async def page(self, request: Request, **kwargs) -> Response:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alchemy(self):
|
||||||
|
return self.constellation.alchemy
|
||||||
|
|
||||||
|
@property
|
||||||
|
def Session(self):
|
||||||
|
return self.constellation.alchemy.Session
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session_acm(self):
|
||||||
|
return self.constellation.alchemy.session_acm
|
||||||
|
|
||||||
|
|
||||||
class PageStar(Star):
|
class PageStar(Star):
|
||||||
path: str = NotImplemented
|
path: str = NotImplemented
|
||||||
|
|
Loading…
Reference in a new issue