Skip to content

Commit

Permalink
Alters arxiv.db so it can be used without flask installed
Browse files Browse the repository at this point in the history
  • Loading branch information
bdc34 committed Sep 16, 2024
1 parent ed5f4ea commit f8827cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arxiv/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@
from contextlib import contextmanager
from typing import Tuple, Optional

from flask.globals import app_ctx
from flask import has_app_context, Flask
try:
from flask.globals import app_ctx
from flask import has_app_context, Flask
except ImportError:
def has_app_context():
return False

from sqlalchemy import Engine, MetaData, create_engine
from sqlalchemy.event import listens_for
Expand Down Expand Up @@ -200,4 +204,4 @@ def init(settings: Settings=settings) -> None:

# late import of arxiv.db.models to avoid loops
from arxiv.db.models import configure_db_engine
configure_db_engine(_classic_engine, _latexml_engine)
configure_db_engine(_classic_engine, _latexml_engine)

0 comments on commit f8827cc

Please sign in to comment.