Skip to content

Commit

Permalink
Create the generate_wsgi_app function as suggested here: Miserlou/Zap…
Browse files Browse the repository at this point in the history
…pa#278 (comment)

Try manually parsing the settings file


oops forgot filename


Add config parser


fix params
  • Loading branch information
brianrower committed Sep 17, 2018
1 parent 42e10c1 commit 3e8857c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions pypicloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pyramid.settings import asbool
from pyramid_beaker import session_factory_from_settings
from six.moves.urllib.parse import urlencode # pylint: disable=F0401,E0611
from configparser import ConfigParser

from .route import Root
from .util import BetterScrapingLocator
Expand Down Expand Up @@ -177,3 +178,13 @@ def main(config, **settings):
config.include("pypicloud")
config.scan("pypicloud.views")
return config.make_wsgi_app()


def generate_wsgi_app(app, environ):
# Read in the settings file and pass that to main
config = ConfigParser()
config.read('server.ini')
settings = dict(config.items('app:main'))

wsgi_app = main(None, **settings)
return wsgi_app(app, environ)
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
REQUIREMENTS = [
"boto3>=1.7.0,<1.8", # Hack until https://github.com/spulec/moto/issues/1793 is fixed
# beaker needs this
"cryptography",
'cryptography',
'configparser',
# We're doing enough subclassing and monkey patching to where we really do
# need to lock this in to a specific version.
"distlib==0.2.5",
Expand Down

0 comments on commit 3e8857c

Please sign in to comment.