Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
WSGI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Mar 10, 2014
1 parent 794ae2d commit 5b59939
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 11 additions & 1 deletion betty/server/utils/runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from logan.runner import run_app
from logan.runner import run_app, configure_app

BETTY_IMAGE_ROOT = os.path.normpath(os.path.join(os.getcwd(), "images"))

Expand All @@ -20,6 +20,16 @@ def generate_settings():
""".format(BETTY_IMAGE_ROOT)


def configure():
configure_app(
project='betty',
default_config_path='betty.conf.py',
default_settings='betty.conf.server',
settings_initializer=generate_settings,
settings_envvar='BETTY_CONF',
)


def main():
run_app(
project='betty',
Expand Down
17 changes: 17 additions & 0 deletions betty/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import os.path
import sys

# Add the project to the python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
sys.stdout = sys.stderr

# Configure the application (Logan)
from betty.server.utils.runner import configure
configure()

# Build the wsgi app
import django.core.handlers.wsgi

# Run WSGI handler for the application
application = django.core.handlers.wsgi.WSGIHandler()
5 changes: 2 additions & 3 deletions tests/test_management_commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import io

import django
from django.core import management
from django.core.management.base import CommandError
Expand All @@ -16,7 +14,8 @@ def test_create_token(self):
def test_create_specific_token(self):
management.call_command("create_token", "noop", "noop")
self.assertEqual(ApiToken.objects.count(), 1)
self.assertEqual(ApiToken.objects.filter(private_token="noop", public_token="noop").count(), 1)
qs = ApiToken.objects.filter(private_token="noop", public_token="noop")
self.assertEqual(qs.count(), 1)

def test_command_error(self):
if django.VERSION[1] > 4:
Expand Down

0 comments on commit 5b59939

Please sign in to comment.