Skip to content

Commit 61bef87

Browse files
authored
Merge pull request #46 from arXiv/0.4.1-fixes
0.4.1rc fixes
2 parents 2de7be8 + c582e91 commit 61bef87

File tree

5 files changed

+109
-55
lines changed

5 files changed

+109
-55
lines changed

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ arxiv-vault = "==0.1.1rc14"
2929
pytz = "*"
3030
arxiv-auth = {path = "./users"}
3131
mimesis = "*"
32+
flask-sqlalchemy = "*"
33+
"flask-s3" = "*"
3234

3335
[dev-packages]
3436
mimesis = "==2.1.0"

Pipfile.lock

Lines changed: 89 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts/accounts/config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import os
44

5-
VERSION = '0.2'
5+
VERSION = '0.4'
6+
APP_VERSION = '0.4'
7+
"""The application version."""
68

79
NAMESPACE = os.environ.get('NAMESPACE')
810
"""Namespace in which this service is deployed; to qualify keys for secrets."""
@@ -134,3 +136,10 @@
134136
'minimum_ttl': 360000}
135137
]
136138
"""Requests for Vault secrets."""
139+
140+
FLASKS3_BUCKET_NAME = os.environ.get('FLASKS3_BUCKET_NAME', 'some_bucket')
141+
FLASKS3_CDN_DOMAIN = os.environ.get('FLASKS3_CDN_DOMAIN', 'static.arxiv.org')
142+
FLASKS3_USE_HTTPS = os.environ.get('FLASKS3_USE_HTTPS', 1)
143+
FLASKS3_FORCE_MIMETYPE = os.environ.get('FLASKS3_FORCE_MIMETYPE', 1)
144+
FLASKS3_ACTIVE = os.environ.get('FLASKS3_ACTIVE', 0)
145+
"""Flask-S3 plugin settings."""

accounts/accounts/factory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Application factory for accounts app."""
22

33
from flask import Flask
4+
from flask_s3 import FlaskS3
45

56
from arxiv import vault
67
from arxiv.base import Base
@@ -10,6 +11,8 @@
1011
from accounts.routes import ui
1112
from accounts.services import SessionStore, legacy, users
1213

14+
s3 = FlaskS3()
15+
1316

1417
def create_web_app() -> Flask:
1518
"""Initialize and configure the accounts application."""
@@ -23,6 +26,7 @@ def create_web_app() -> Flask:
2326
app.register_blueprint(ui.blueprint)
2427
Base(app) # Gives us access to the base UI templates and resources.
2528
auth.Auth(app) # Handless sessions and authn/z.
29+
s3.init_app(app)
2630

2731
middleware = [auth.middleware.AuthMiddleware]
2832
if app.config['VAULT_ENABLED']:

accounts/wsgi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from accounts.factory import create_web_app
44
import os
55

6-
__flask_app__ = create_web_app()
7-
6+
__flask_app__ = None
87

98
def application(environ, start_response): # type: ignore
109
"""WSGI application."""
@@ -17,5 +16,7 @@ def application(environ, start_response): # type: ignore
1716
if key == 'SERVER_NAME':
1817
continue
1918
os.environ[key] = str(value)
20-
__flask_app__.config[key] = str(value)
19+
global __flask_app__
20+
if __flask_app__ is None:
21+
__flask_app__ = create_web_app()
2122
return __flask_app__(environ, start_response)

0 commit comments

Comments
 (0)