fix: just use upstream main()
for webapi
apparently this demo is not customizing anything and had some old code which no longer works (auth policy)
This commit is contained in:
parent
c67494a18c
commit
beddcf6987
|
@ -3,50 +3,11 @@
|
||||||
Rattail Demo web API
|
Rattail Demo web API
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
from tailbone import webapi as base
|
||||||
|
|
||||||
from pyramid.config import Configurator
|
|
||||||
from pyramid.authentication import SessionAuthenticationPolicy
|
|
||||||
|
|
||||||
from tailbone import app
|
|
||||||
from tailbone.auth import TailboneAuthorizationPolicy
|
|
||||||
|
|
||||||
|
|
||||||
def main(global_config, **settings):
|
def main(global_config, **settings):
|
||||||
"""
|
"""
|
||||||
This function returns a Pyramid WSGI application.
|
This function returns a Pyramid WSGI application.
|
||||||
"""
|
"""
|
||||||
# make config objects
|
return base.main(global_config, **settings)
|
||||||
rattail_config = app.make_rattail_config(settings)
|
|
||||||
pyramid_config = Configurator(settings=settings, root_factory=app.Root)
|
|
||||||
|
|
||||||
# configure user authorization / authentication
|
|
||||||
pyramid_config.set_authorization_policy(TailboneAuthorizationPolicy())
|
|
||||||
pyramid_config.set_authentication_policy(SessionAuthenticationPolicy())
|
|
||||||
|
|
||||||
# always require CSRF token protection
|
|
||||||
pyramid_config.set_default_csrf_options(require_csrf=True, token='_csrf', header='X-XSRF-TOKEN')
|
|
||||||
|
|
||||||
# bring in some Pyramid goodies
|
|
||||||
pyramid_config.include('tailbone.beaker')
|
|
||||||
pyramid_config.include('pyramid_tm')
|
|
||||||
pyramid_config.include('cornice')
|
|
||||||
|
|
||||||
# bring in the pyramid_retry logic, if available
|
|
||||||
# TODO: pretty soon we can require this package, hopefully..
|
|
||||||
try:
|
|
||||||
import pyramid_retry
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
pyramid_config.include('pyramid_retry')
|
|
||||||
|
|
||||||
# add some permissions magic
|
|
||||||
pyramid_config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group')
|
|
||||||
pyramid_config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')
|
|
||||||
|
|
||||||
# bring in some Tailbone
|
|
||||||
pyramid_config.include('tailbone.subscribers')
|
|
||||||
pyramid_config.include('tailbone.api')
|
|
||||||
|
|
||||||
return pyramid_config.make_wsgi_app()
|
|
||||||
|
|
Loading…
Reference in a new issue