Beispiel #1
0
"""
WSGI config for api project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os
from raven.contrib.django.middleware.wsgi import Sentry
from whitenoise.django import DjangoWhiteNoise
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                      "osmaxx_conversion_service.config.settings.production")

application = get_wsgi_application()
application = Sentry(DjangoWhiteNoise(application))
Beispiel #2
0
"""
WSGI config for gswd project.

This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.

Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.

"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gswd.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
from raven.contrib.django.middleware.wsgi import Sentry

application = Sentry(get_wsgi_application())

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
Beispiel #3
0
:copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

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 sentry.utils.runner import configure
configure()

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

from django.conf import settings
from raven.contrib.django.middleware.wsgi import Sentry

if settings.SESSION_FILE_PATH and not os.path.exists(settings.SESSION_FILE_PATH):
    try:
        os.makedirs(settings.SESSION_FILE_PATH)
    except OSError:
        pass

# Run WSGI handler for the application
application = Sentry(django.core.handlers.wsgi.WSGIHandler())
Beispiel #4
0
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pyweek.settings")

# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

from raven.contrib.django.middleware.wsgi import Sentry

application = Sentry(application)

raw_app = application


def application(environ, start_response):
    """Quick WSGI middleware to set host and scheme headers."""
    environ.update(
        HTTP_HOST='pyweek.org',
        HTTP_X_FORWARDED_PROTO='https',
    )
    return raw_app(environ, start_response)
    except OSError:
        pass

from django.core.handlers.wsgi import WSGIHandler


class FileWrapperWSGIHandler(WSGIHandler):
    """A WSGIHandler implementation that handles a StreamingHttpResponse
    from django to leverage wsgi.file_wrapper for delivering large streaming
    responses.

    Note: this was added natively into Django 1.8, so if by some reason,
    we upgraded, this wouldn't be relevant anymore."""
    def __call__(self, environ, start_response):
        response = super(FileWrapperWSGIHandler,
                         self).__call__(environ, start_response)
        if hasattr(response, 'streaming') and response.streaming:
            try:
                response = environ['wsgi.file_wrapper'](
                    response.streaming_content)
            except KeyError:
                # In our case, we're shipping with uwsgi, so it's safer to assume
                # that wsgi.file_wrapper does exist. It'd be exceptional otherwise.
                pass
        return response


# Run WSGI handler for the application
from raven.contrib.django.middleware.wsgi import Sentry
application = Sentry(FileWrapperWSGIHandler())