def test_config_searchpath(): config = Mock() config.add_static_view = Mock() from deform_bootstrap import includeme includeme(config) config.add_static_view.assert_called_once_with('static-deform_bootstrap', 'deform_bootstrap:static')
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ if not 'pyramid.secretcookie' in settings: log.error('pyramid.secretcookie is not set. Refusing to start.') quit(-1) if not 'pyramid.auth.secret' in settings: log.error('pyramid.auth.secret is not set. Refusing to start.') quit(-1) if not 'defcne.upload_path' in settings: log.error('defcne.upload_path is not set. Refusing to start.') quit(-1) if not 'defcne.registration_open' in settings: log.error('defcne.registration_open is not set. Refusing to start.') quit(-1) else: settings['defcne.registration_open'] = asbool(settings['defcne.registration_open']) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) config = Configurator(settings=settings) _session_factory = SignedCookieSessionFactory( settings['pyramid.secretcookie'], httponly=True, max_age=864000 ) _authn_policy = AuthTktAuthenticationPolicy( settings['pyramid.auth.secret'], max_age=864000, http_only=True, debug=True, hashalg='sha512', callback=auth.user_groups, ) _authz_policy = ACLAuthorizationPolicy() config.set_session_factory(_session_factory) config.set_authentication_policy(_authn_policy) config.set_authorization_policy(_authz_policy) config.include(add_routes) config.include(add_views) config.include(add_events) deform_bootstrap.includeme(config) config.set_request_property(auth.current_user, 'user', reify=True) config.include('pyramid_mailer') return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ # session factory session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet') config = Configurator(settings=settings, session_factory=session_factory) config.set_request_property(get_extensions, name="ext") includeme(config) config.add_static_view('static', 'static', cache_max_age=3600) config.add_static_view('deform_static', 'deform:static') config.add_route('home', '/') config.add_route('mlp', '/mlp') config.add_route('delta', '/delta') config.add_route('changes', '/changes') config.add_route('hop', '/hopfield') config.add_route('hop_learn', '/hopfield/learn') config.add_route('hop_energy', '/hopfield/energy') config.scan() return config.make_wsgi_app()