Make importing backends easier

This commit is contained in:
Tim Van Baak 2021-06-28 21:13:14 -07:00
parent 06d662982c
commit 74fe79dbf9
14 changed files with 26 additions and 24 deletions

View File

@ -0,0 +1,9 @@
import amanuensis.backend.article as artiq
import amanuensis.backend.character as charq
import amanuensis.backend.index as indq
import amanuensis.backend.lexicon as lexiq
import amanuensis.backend.membership as memq
import amanuensis.backend.post as postq
import amanuensis.backend.user as userq
__all__ = ["artiq", "charq", "indq", "lexiq", "memq", "postq", "userq"]

View File

@ -2,9 +2,7 @@ import logging
from sqlalchemy import update from sqlalchemy import update
import amanuensis.backend.lexicon as lexiq from amanuensis.backend import lexiq, memq, userq
import amanuensis.backend.membership as memq
import amanuensis.backend.user as userq
from amanuensis.db import DbContext, Lexicon from amanuensis.db import DbContext, Lexicon
from .helpers import add_argument from .helpers import add_argument

View File

@ -1,7 +1,7 @@
import logging import logging
from typing import Optional from typing import Optional
import amanuensis.backend.user as userq from amanuensis.backend import userq
from amanuensis.db import DbContext, User from amanuensis.db import DbContext, User
from .helpers import add_argument from .helpers import add_argument

View File

@ -4,8 +4,7 @@ import os
from flask import Flask, g from flask import Flask, g
import amanuensis.backend.lexicon from amanuensis.backend import lexiq, userq
import amanuensis.backend.user
from amanuensis.config import AmanuensisConfig, CommandLineConfig from amanuensis.config import AmanuensisConfig, CommandLineConfig
from amanuensis.db import DbContext from amanuensis.db import DbContext
import amanuensis.server.auth as auth import amanuensis.server.auth as auth
@ -61,7 +60,7 @@ def get_app(
app.template_filter("date")(date_format) app.template_filter("date")(date_format)
def include_backend(): def include_backend():
return {"db": db, "lexiq": amanuensis.backend.lexicon, "userq": amanuensis.backend.user} return {"db": db, "lexiq": lexiq, "userq": userq}
app.context_processor(include_backend) app.context_processor(include_backend)

View File

@ -17,7 +17,7 @@ from flask_login import (
LoginManager, LoginManager,
) )
import amanuensis.backend.user as userq from amanuensis.backend import userq
from amanuensis.db import User from amanuensis.db import User
from .forms import LoginForm from .forms import LoginForm

View File

@ -1,7 +1,6 @@
from flask import Blueprint, render_template, g from flask import Blueprint, render_template, g
import amanuensis.backend.user as userq from amanuensis.backend import userq, lexiq
import amanuensis.backend.lexicon as lexiq
# from .forms import LexiconCreateForm # from .forms import LexiconCreateForm

View File

@ -1,9 +1,9 @@
import pytest import pytest
import time import time
from amanuensis.db import DbContext from amanuensis.backend import artiq
from amanuensis.db.models import Character, Lexicon, User from amanuensis.db import DbContext, Character, Lexicon, User
import amanuensis.backend.article as artiq
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError
from tests.conftest import ObjectFactory from tests.conftest import ObjectFactory

View File

@ -1,7 +1,7 @@
import pytest import pytest
from amanuensis.backend import charq
from amanuensis.db import * from amanuensis.db import *
import amanuensis.backend.character as charq
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError

View File

@ -1,8 +1,8 @@
from amanuensis.db.models import IndexType from amanuensis.db.models import IndexType
import pytest import pytest
import amanuensis.backend.index as indq from amanuensis.backend import indq
from amanuensis.db import DbContext, Lexicon, User from amanuensis.db import DbContext, Lexicon
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError

View File

@ -3,7 +3,7 @@ import time
import pytest import pytest
import amanuensis.backend.lexicon as lexiq from amanuensis.backend import lexiq
from amanuensis.db import DbContext, Lexicon, User from amanuensis.db import DbContext, Lexicon, User
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError
from tests.conftest import ObjectFactory from tests.conftest import ObjectFactory

View File

@ -2,9 +2,9 @@ import pytest
from sqlalchemy import select from sqlalchemy import select
from amanuensis.backend import memq
from amanuensis.db import * from amanuensis.db import *
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError
import amanuensis.backend.membership as memq
def test_create_membership(db: DbContext, make): def test_create_membership(db: DbContext, make):

View File

@ -1,7 +1,7 @@
import pytest import pytest
from amanuensis.backend import postq
from amanuensis.db import DbContext from amanuensis.db import DbContext
import amanuensis.backend.post as postq
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError

View File

@ -2,7 +2,7 @@ import os
import pytest import pytest
import amanuensis.backend.user as userq from amanuensis.backend import userq
from amanuensis.db import DbContext, User from amanuensis.db import DbContext, User
from amanuensis.errors import ArgumentError from amanuensis.errors import ArgumentError

View File

@ -10,10 +10,7 @@ from bs4 import BeautifulSoup
from flask.testing import FlaskClient from flask.testing import FlaskClient
from sqlalchemy.orm.session import close_all_sessions from sqlalchemy.orm.session import close_all_sessions
import amanuensis.backend.character as charq from amanuensis.backend import charq, lexiq, memq, userq
import amanuensis.backend.lexicon as lexiq
import amanuensis.backend.membership as memq
import amanuensis.backend.user as userq
from amanuensis.config import AmanuensisConfig from amanuensis.config import AmanuensisConfig
from amanuensis.db import DbContext, User, Lexicon, Membership, Character from amanuensis.db import DbContext, User, Lexicon, Membership, Character
from amanuensis.server import get_app from amanuensis.server import get_app