Пример #1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)

    json_renderer = JSON()

    def datetime_adapter(obj, request):
        return obj.isoformat()

    json_renderer.add_adapter(datetime, datetime_adapter)
    config.add_renderer('json', json_renderer)

    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.set_authentication_policy(MixedTokenAuthenticationPolicy())
    config.set_authorization_policy(
        AlwaysPassAuthenticatedAuthorizationPolicy()
    )

    enabled_registration_modules = settings.get(
        'pydiditpyramidgateway.enabled_registration_modules'
    )
    if enabled_registration_modules is not None:
        enabled_registration_modules = config.maybe_dotted(
            enabled_registration_modules.split(',')
        )
        for module in enabled_registration_modules:
            config.include(module)

    config.scan()
    pydiditbackend.initialize(json.loads(settings['backend_settings']))
    return config.make_wsgi_app()
Пример #2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    initialize()
    config.scan()
    return config.make_wsgi_app()
Пример #3
0
def setUp():
    initialize("pydidit_test.ini")
    Base.metadata.create_all()
Пример #4
0
from pyramid.response import Response
from pyramid.view import view_config
from pyramid.config import Configurator

from sqlalchemy.exc import DBAPIError

from .models import (
    DBSession,
    #MyModel,
    )

# We can't survive without it.
import pydiditbackend as b
b.initialize()


import json
import datetime

# Used for converting datetime in out json.
def datetime_handler(obj):
    return obj.isoformat() if hasattr(obj, 'isoformat') else obj

@view_config(route_name='pydidit', renderer='templates/pydidit.pt')
def pydidit(request):
#    try:
#        one = DBSession.query(MyModel).filter(MyModel.name == 'one').first()
#    except DBAPIError:
#        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {}