def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ global check_username check_username = lambda username, password:\ settings['gmusicapi_username'] == username and\ settings['gmusicapi_password'] == password if not gm.login(settings['gmusicapi_username'], settings['gmusicapi_password']): logger.warn("Unable to login to Google Music!") exit() if not wc.login(settings['gmusicapi_username'], settings['gmusicapi_password']): logger.warn("Unable to login to Google Music!") exit() engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine set_cache_regions_from_settings(settings) config = Configurator(settings=settings) config.include('pyramid_chameleon') config.include('gmusic.views') config.add_static_view('static', 'static', cache_max_age=3600) config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder) authorization_policy = ACLAuthorizationPolicy() config = Configurator( settings = settings , authentication_policy = authentication_policy , authorization_policy=authorization_policy ) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) config.registry.registerUtility(DBSession, IDBSession) config.override_asset( to_override='hiero:templates/blog_index.mako', override_with='sontek:templates/blog_index.mako' ) config.override_asset( to_override='hiero:templates/entry_detail.mako', override_with='sontek:templates/entry_detail.mako' ) config.include('sontek.routes') config.scan() return config.make_wsgi_app()
class Test_model_url_filter(unittest.TestCase): def setUp(self): self.environment = Environment() from pyramid_jinja2.filters import model_url_filter self.environment.filters['model_url'] = model_url_filter from pyramid.config import Configurator self.config = Configurator(autocommit=True) self.config.begin(request=DummyRequest()) def tearDown(self): self.config.end() def _callFUT(self, context, tmpl): tmpl = self.environment.from_string(tmpl) return tmpl.render(**context) def test_filter(self): model = DummyModel() rendered = self._callFUT({'model':model}, '{{model|model_url}}') self.assertEqual(rendered, 'http://example.com/dummy/') def test_filter_with_elements(self): model = DummyModel() rendered = self._callFUT({'model':model}, "{{model|model_url('edit')}}") self.assertEqual(rendered, 'http://example.com/dummy/edit')
def test_it(self): from pyramid.config import Configurator from pyramid_handlers import add_handler from pyramid_handlers import includeme c = Configurator(autocommit=True) c.include(includeme) self.assertTrue(c.add_handler.__func__.__docobj__ is add_handler)
def test_pyramid_directive(self): from pyramid.config import Configurator config = Configurator() config.include('ptah') self.assertTrue(hasattr(config, 'ptah_migrate'))
def main(global_config, **settings): config = Configurator(settings=settings) config.include('pyramid_chameleon') config.add_route('home', '/') config.add_route('hello', '/howdy') config.scan('.views') return config.make_wsgi_app()
def registerDummySecurityPolicy(userid=None, groupids=(), permissive=True): """ Registers a pair of faux :app:`Pyramid` security policies: a :term:`authentication policy` and a :term:`authorization policy`. The behavior of the registered :term:`authorization policy` depends on the ``permissive`` argument. If ``permissive`` is true, a permissive :term:`authorization policy` is registered; this policy allows all access. If ``permissive`` is false, a nonpermissive :term:`authorization policy` is registered; this policy denies all access. The behavior of the registered :term:`authentication policy` depends on the values provided for the ``userid`` and ``groupids`` argument. The authentication policy will return the userid identifier implied by the ``userid`` argument and the group ids implied by the ``groupids`` argument when the :func:`pyramid.security.authenticated_userid` or :func:`pyramid.security.effective_principals` APIs are used. This function is most useful when testing code that uses the APIs named :func:`pyramid.security.has_permission`, :func:`pyramid.security.authenticated_userid`, :func:`pyramid.security.unauthenticated_userid`, :func:`pyramid.security.effective_principals`, and :func:`pyramid.security.principals_allowed_by_permission`. """ registry = get_current_registry() config = Configurator(registry=registry) result = config.testing_securitypolicy(userid=userid, groupids=groupids, permissive=permissive) config.commit() return result
def _make_config(self, settings={}): all_settings = self.DEFAULT_SETTINGS.copy() all_settings.update(settings) config = Configurator(settings=all_settings) config.include("tokenserver") config.commit() return config
def main(argv=sys.argv): # Usage and configuration if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) config = Configurator(settings=settings) config.include('pyramid_sqlalchemy') # Make the database with schema and default data with transaction.manager: metadata.create_all() root = RootFolder(name='', title='Moonbase Demo', __acl__=[ ['Allow', ['paul'], 'view'] ] ) Session.add(root) f1 = root['f1'] = Folder( title='Folder 1', __acl__=[ ['Allow', ['shane'], 'view'] ] ) f1['da'] = Document(title='Document 1A')
def make_app(cls, settings=None, config=None): settings = cls.get_app_settings(settings) config = Configurator(settings=settings) for event_cls in cls.subscribed: config.add_subscriber(cls.listener, event_cls) config.commit() return super().make_app(settings=settings, config=config)
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ load_project_settings() session_factory = UnencryptedCookieSessionFactoryConfig(settings.get('session.secret', 'hello')) engine = engine_from_config(settings, 'sqlalchemy.') db.configure(bind=engine) config = Configurator(session_factory=session_factory, settings=settings) config.add_tween('droneos_ui.auth.authenticator') config.include('pyramid_handlers') config.add_view('pyramid.view.append_slash_notfound_view', context='pyramid.httpexceptions.HTTPNotFound') add_admin_handler(config, db, get_models(droneos_ui), 'admin.', '/admin', AdminController) application_routes(config) configure_app_routes(config) all_apps = get_submodules(apps) ignored_apps = [] for app in all_apps: if app['is_package'] and app['name'] not in enabled_apps: ignored_apps.append('.apps.' + app['name']) config.scan(ignore=ignored_apps) return config.make_wsgi_app()
class TestServiceDefinition(unittest2.TestCase): def setUp(self): if not metlog: raise(unittest2.SkipTest('no metlog')) mozconfig = Config(StringIO(dedent(""" [test1] backend = mozsvc.metrics.MetlogPlugin sender_class=metlog.senders.DebugCaptureSender """))) settings = {"config": mozconfig} self.plugin = load_from_config("test1", mozconfig) self.config = Configurator(settings=settings) self.config.include("cornice") self.config.scan("mozsvc.tests.test_service_definition") self.app = TestApp(CatchErrors(self.config.make_wsgi_app())) def tearDown(self): testing.tearDown() def test_decorated_view_fn(self): # passing a decorator in to the service api call should result in a # decorated view callable resp = self.app.get("/service3") self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'}) def test_stacked_decorated_view(self): # passing a decorator in to the service api call should result in a # decorated view callable, ordering of the particular decorators # shouldn't break things resp = self.app.get("/service4") self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'}) resp = self.app.get("/service5") self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'})
def app(): config = Configurator() config.include('pyramid_wiring') graph = Graph() graph.register_scope(RequestScope, RequestScope()) class Counter(object): def __init__(self): self.count = 1 graph.register_provider('counter', FactoryProvider(Counter, scope=RequestScope)) config.set_object_graph(graph) def count(request, counter=injected('counter')): # Increment the counter count = counter.count counter.count += 1 # Get the counter from the graph again and make sure it's the same assert graph.get('counter') is counter return count config.add_route('count', '/count') config.add_view(count, route_name='count', renderer='string') return TestApp(config.make_wsgi_app())
def registerResources(resources): """ Registers a dictionary of :term:`resource` objects that can be resolved via the :func:`pyramid.traversal.find_resource` API. The :func:`pyramid.traversal.find_resource` API is called with a path as one of its arguments. If the dictionary you register when calling this method contains that path as a string key (e.g. ``/foo/bar`` or ``foo/bar``), the corresponding value will be returned to ``find_resource`` (and thus to your code) when :func:`pyramid.traversal.find_resource` is called with an equivalent path string or tuple. .. warning:: This API is deprecated as of :app:`Pyramid` 1.0. Instead use the :meth:`pyramid.config.Configurator.testing_resources` method in your unit and integration tests. .. note:: For ancient backward compatibility purposes, this API can also be accessed as :func:`pyramid.testing.registerModels`. """ registry = get_current_registry() config = Configurator(registry=registry) result = config.testing_resources(resources) config.commit() return result
def registerEventListener(event_iface=None): """ Registers an :term:`event` listener (aka :term:`subscriber`) listening for events of the type ``event_iface``. This method returns a list object which is appended to by the subscriber whenever an event is captured. When an event is dispatched that matches ``event_iface``, that event will be appended to the list. You can then compare the values in the list to expected event notifications. This method is useful when testing code that wants to call :meth:`pyramid.registry.Registry.notify`, :func:`zope.component.event.dispatch` or :func:`zope.component.event.objectEventNotify`. The default value of ``event_iface`` (``None``) implies a subscriber registered for *any* kind of event. .. warning:: This API is deprecated as of :app:`Pyramid` 1.0. Instead use the :meth:`pyramid.config.Configurator.testing_add_subscriber` method in your unit and integration tests. """ registry = get_current_registry() config = Configurator(registry=registry) result = config.testing_add_subscriber(event_iface) config.commit() return result
def registerSubscriber(subscriber, iface=Interface): """ Register a ZCA subscriber component. The ``subscriber`` argument specifies the implementation of the subscriber component (often a function). The ``iface`` argument is the interface type for which the subscriber will be registered (:class:`zope.interface.Interface` by default). If ``iface`` is not a tuple or list, it will be converted to a one-tuple before being passed to the underlying ZCA :meth:`pyramid.registry.registerHandler` method. See `The ZCA book <http://www.muthukadan.net/docs/zca.html>`_ for more information about ZCA subscribers. .. warning:: This API is deprecated as of :app:`Pyramid` 1.0. Instead use the :meth:`pyramid.config.Configurator.add_subscriber` method in your unit and integration tests. """ registry = get_current_registry() config = Configurator(registry) result = config.add_subscriber(subscriber, iface=iface) config.commit() return result
def registerSettings(dictarg=None, **kw): """Register one or more 'setting' key/value pairs. A setting is a single key/value pair in the dictionary-ish object returned from the API :attr:`pyramid.registry.Registry.settings`. You may pass a dictionary:: registerSettings({'external_uri':'http://example.com'}) Or a set of key/value pairs:: registerSettings(external_uri='http://example.com') Use of this function is required when you need to test code that calls the :attr:`pyramid.registry.Registry.settings` API and which uses return values from that API. .. warning:: This API is deprecated as of :app:`Pyramid` 1.0. Instead use the :meth:`pyramid.config.Configurator.add_settings` method in your unit and integration tests. """ registry = get_current_registry() config = Configurator(registry=registry) config.add_settings(dictarg, **kw)
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine session_factory = session_factory_from_settings(settings) authn_policy = AuthTktAuthenticationPolicy('s0secret', callback=groupfinder, hashalg='md5') #authn_policy = AuthTktAuthenticationPolicy('s0secret') authz_policy = ACLAuthorizationPolicy() config = Configurator( settings=settings, root_factory=RootFactory, authentication_policy=authn_policy, authorization_policy=authz_policy, session_factory=session_factory ) # since version 1.5 templating is not included by default config.include('pyramid_chameleon') config.add_static_view('static', 'static', cache_max_age=3600) config.include(addroutes) config.scan() return config.make_wsgi_app()
def test_parent_queryset_es(self): from pyramid.config import Configurator from ramses.acl import BaseACL config = Configurator() config.include('nefertari') root = config.get_root_resource() user = root.add( 'user', 'users', id_name='username', view=views.ESBaseView, factory=BaseACL) user.add( 'story', 'stories', id_name='prof_id', view=views.ESBaseView, factory=BaseACL) view_cls = root.resource_map['user:story'].view request = Mock( registry={'foo': 'bar'}, path='/foo/foo', matchdict={'username': '******', 'prof_id': 4}, accept=[''], method='GET' ) request.params.mixed.return_value = {'foo1': 'bar1'} request.blank.return_value = request stories_view = view_cls( request=request, context={}, _query_params={'foo1': 'bar1'}, _json_params={'foo2': 'bar2'},) parent_view = stories_view._resource.parent.view with patch.object(parent_view, 'get_item_es') as get_item_es: parent_view.get_item_es = get_item_es result = stories_view._parent_queryset_es() get_item_es.assert_called_once_with(username='******') assert result == get_item_es().stories
def _apply_parent_actions(parent_registry): toolbar_app = parent_registry.queryUtility(IToolbarWSGIApp) if toolbar_app is None: # this registry does not have a debugtoolbar attached return toolbar_registry = toolbar_app.registry # inject the BeforeRender subscriber after the application is created # and all other subscribers are registered in hopes that this will be # the last subscriber in the chain and will be able to see the effects # of all previous subscribers on the event parent_config = Configurator(registry=parent_registry, introspection=False) parent_config.add_subscriber( 'pyramid_debugtoolbar.toolbar.beforerender_subscriber', 'pyramid.events.BeforeRender', ) actions = toolbar_registry.queryUtility(IParentActions, default=[]) for action in actions: action(parent_config) # overwrite actions after they have been applied to avoid applying them # twice - but leave it as a new list incase someone adds more actions later # and calls config.make_wsgi_app() again... this would mainly be necessary # for tests that call config.make_wsgi_app() multiple times. toolbar_registry.registerUtility([], IParentActions) parent_config.commit()
def _makeOne(self, autocommit=True): from pyramid.config import Configurator from pyramid_handlers import add_handler config = Configurator(autocommit=autocommit) config.add_directive("add_handler", add_handler) return config
def _makeOne(self, autocommit=True): from pyramid.config import Configurator import pyramid_handlers from papyrus import add_papyrus_routes config = Configurator(autocommit=autocommit) config.add_directive('add_papyrus_routes', add_papyrus_routes) return config
def test_handle_submit_key_expired(self): reg = get_current_registry() config = Configurator(reg) renderer = config.testing_add_template('templates/reset_failed.pt') request = self.request request.params['key'] = '0' * 40 self._setupUsers() context = self.context context['profiles'] = testing.DummyModel() profile = context['profiles']['me'] = testing.DummyModel() profile.password_reset_key = '0' * 40 controller = self._makeOne(context, request) converted = {'login': '******'} # first w/ no profile reset time response = controller.handle_submit(converted) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset Confirmation Key Expired') # now w/ expired key renderer = config.testing_add_template('templates/reset_failed.pt') from karl.views.resetpassword import max_reset_timedelta import datetime keytime = datetime.datetime.now() - max_reset_timedelta profile.password_reset_time = keytime response = controller.handle_submit(converted) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset Confirmation Key Expired')
def test___call__bad_key(self): # register dummy renderer for the email template reg = get_current_registry() config = Configurator(reg) renderer = config.testing_add_template('templates/reset_failed.pt') request = self.request request.layout_manager = mock.Mock() # no key controller = self._makeOne(self.context, request) response = controller() from pyramid.response import Response self.assertEqual(response.__class__, Response) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset URL Problem') # reset renderer.api value so we know the test is useful renderer = config.testing_add_template('templates/reset_failed.pt') # key of wrong length request.params['key'] = 'foofoofoo' controller = self._makeOne(self.context, request) response = controller() from pyramid.response import Response self.assertEqual(response.__class__, Response) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset URL Problem')
def test_handle_submit_wrong_key(self): reg = get_current_registry() config = Configurator(reg) renderer = config.testing_add_template('templates/reset_failed.pt') request = self.request request.params['key'] = '0' * 40 self._setupUsers() context = self.context context['profiles'] = testing.DummyModel() context['profiles']['me'] = testing.DummyModel() controller = self._makeOne(context, request) converted = {'login': '******'} # first w/ no profile reset key response = controller.handle_submit(converted) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset Confirmation Problem') # now w/ wrong profile reset key renderer = config.testing_add_template('templates/reset_failed.pt') context['profiles']['me'].password_reset_key = '1' * 40 response = controller.handle_submit(converted) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset Confirmation Problem')
def get_app( tool_definition, data_folder, website_name=None, website_owner=None, website_url=None): settings = { 'data.folder': data_folder, 'website.name': website_name or WEBSITE['name'], 'website.owner': website_owner or WEBSITE['owner'], 'website.url': website_url or WEBSITE['url'], 'website.root_assets': [ 'invisibleroads_posts:assets/favicon.ico', 'invisibleroads_posts:assets/robots.txt', ], 'uploads.upload.id.length': 32, 'client_cache.http.expiration_time': 3600, 'jinja2.directories': 'crosscompute:templates', 'jinja2.lstrip_blocks': True, 'jinja2.trim_blocks': True, } settings['tool_definition'] = tool_definition config = Configurator(settings=settings) config.include('invisibleroads_posts') includeme(config) add_routes(config) add_routes_for_fused_assets(config) return config.make_wsgi_app()
def create_app(settings): from horus import groupfinder from pyramid.config import Configurator from pyramid.authentication import AuthTktAuthenticationPolicy from pyramid.authorization import ACLAuthorizationPolicy settings.setdefault('horus.activation_class', 'h.models.Activation') settings.setdefault('horus.user_class', 'h.models.User') authn_policy = AuthTktAuthenticationPolicy( settings['auth.secret'], callback=groupfinder ) authz_policy = ACLAuthorizationPolicy() config = Configurator( settings=settings, authentication_policy=authn_policy, authorization_policy=authz_policy, root_factory='h.resources.RootFactory' ) config.include(includeme) return config.make_wsgi_app()
def test_handle_submit_utf8_password(self): password = u'password\xe1' reg = get_current_registry() config = Configurator(reg) renderer = config.testing_add_template('templates/reset_complete.pt') request = self.request request.params['key'] = '0' * 40 self._setupUsers() context = self.context context['profiles'] = testing.DummyModel() profile = context['profiles']['me'] = testing.DummyModel() profile.password_reset_key = '0' * 40 controller = self._makeOne(context, request) converted = {'login': '******', 'password': password} import datetime keytime = datetime.datetime.now() profile.password_reset_time = keytime response = controller.handle_submit(converted) self.failUnless(hasattr(renderer, 'api')) self.assertEqual(renderer.api.page_title, 'Password Reset Complete') renderer.assert_(login='******', password=password) self.failUnless(profile.password_reset_key is None) self.failUnless(profile.password_reset_time is None) user = self.context.users.get(login='******') from repoze.who.plugins.zodb.users import get_sha_password self.assertEqual(user['password'], get_sha_password(password.encode('utf8')))
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) cache.cache = cache.configure_cache(settings) config = Configurator( settings=settings, root_factory=RootFactory, locale_negotiator=locale_neg ) config.add_route_predicate('vhost', VHostPredicate) config.add_view_predicate('vhost', VHostPredicate) mmgr = config.registry.getUtility(IModuleManager) mmgr.load('core') mmgr.load_enabled() rts = rt.configure(mmgr, config.registry) app = rts.app() rt.run(rts, app)
def main(global_config, **settings): """ This function returns a WSGI application. It is usually called by the PasteDeploy framework during ``paster serve``. """ settings = dict(settings) settings.setdefault('jinja2.i18n.domain', 'hello_world') # Start Sphinx Include 2 my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet') config = Configurator(root_factory=get_root, settings=settings, session_factory=my_session_factory) # End Sphinx Include 2 config.add_translation_dirs('locale/') # Start Include config.include('pyramid_jinja2') # End Include config.add_static_view('static', 'static') config.add_view('hello_world.views.my_view', context='hello_world.models.MyModel', renderer="mytemplate.jinja2") return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application.""" settings["sqlalchemy.url"] = os.environ["DATABASE_URL"] config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.include('.security') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): settings.setdefault('jinja2.i18n.domain', 'CheesePrism') session_factory = UnencryptedCookieSessionFactoryConfig('cheeseprism') config = Configurator(root_factory=App, settings=settings, session_factory=session_factory, authentication_policy=\ BasicAuthenticationPolicy(BasicAuthenticationPolicy.noop_check)) config.add_translation_dirs('locale/') config.include('pyramid_jinja2') config.add_renderer('.html', renderer_factory) config.add_static_view('static', 'static') config.scan('cheeseprism.views') config.scan('cheeseprism.index') config.set_request_factory(Request) config.add_route('package', 'package/{name}/{version}', view='cheeseprism.views.from_pypi') settings['index_templates'] = EnvFactory.from_str( settings['cheeseprism.index_templates']) return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) config = Configurator(settings=settings) config.configure_celery(global_config['__file__']) config.add_route('index', '/') config.add_route('add_task', '/add_task') config.add_route('delete_task', '/delete_task/{task_pk}') config.scan() return config.make_wsgi_app()
from pyramid.view import view_config from pyramid.config import Configurator import logging logging.basicConfig(level=logging.DEBUG) def includeme(config): config.include('.kafka') config.add_route('app', '/') config.scan('.') @view_config(route_name='app') def app_route(request): request.response.status_int = 200 return request.response config = Configurator() config.include(includeme) application = config.make_wsgi_app()
def main(global_config, **settings): engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) if 'timezone' in settings: temporal.default_timezone = pytz.timezone(settings['timezone']) authn_policy = AuthTktAuthenticationPolicy(settings['secret.authn_policy'], callback=permission_finder) authz_policy = ACLAuthorizationPolicy() session_factory = UnencryptedCookieSessionFactoryConfig( settings['secret.unencrypted_cookie']) config = Configurator(settings=settings, root_factory='pyconca.security.RootFactory', session_factory=session_factory) config.add_translation_dirs('pyconca:locale/') config.set_authentication_policy(authn_policy) config.set_authorization_policy(authz_policy) config.set_request_property(get_user, 'user', reify=True) config.add_static_view('static', 'static', cache_max_age=3600) _setup_routes(config) _add_api_resource(config, 'user') _add_resource(config, 'user') _add_api_resource(config, 'talk') _add_resource(config, 'talk') _add_api_resource(config, 'schedule_slot') config.scan() config.set_locale_negotiator("pyconca.locale.locale_negotiator") config.add_subscriber('pyconca.subscribers.add_localizer', 'pyramid.events.NewRequest') config.add_subscriber('pyconca.subscribers.add_renderer_globals', 'pyramid.events.BeforeRender') config.add_subscriber('pyconca.subscribers.add_template_globals', 'pyramid.events.BeforeRender') return config.make_wsgi_app()
from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response def hello_world(request): return Response("Hello %(name)s, I'm a pyramid web app!" % request.matchdict) config = Configurator() config.add_route('hello', '/pyramid/{name}') config.add_view(hello_world, route_name='hello') app = config.make_wsgi_app() # if __name__ == '__main__': # config = Configurator() # config.add_route('hello', '{name}') # config.add_view(hello_world, route_name='hello') # app = config.make_wsgi_app() # server = make_server('0.0.0.0', 8080, app) # server.serve_forever()
except ValueError as e: raise HTTPBadRequest(e) return {"id": fwi.add(j)} @view_config(route_name='recipe_api_one', renderer='json') def recipe_api_one(request): id = request.matchdict['id'] try: id = int(id) except ValueError as e: raise e return fwi[id] config = Configurator() config.add_route('recipe_new', '/recipe/new') config.add_route('recipe_one', '/recipe/{id}') config.add_route('recipe_api_new', '/recipe/api/new') config.add_route('recipe_api_one', '/recipe/api/{id}') config.include('pyramid_jinja2') thisDirectory = os.path.dirname(os.path.realpath(__file__)) config.add_jinja2_search_path(thisDirectory) config.commit() jinja2_env = config.get_jinja2_environment() jinja2_env.autoescape = False config.scan() app = config.make_wsgi_app() if __name__ == '__main__':
def _makeOne(self, *arg, **kw): from pyramid.config import Configurator config = Configurator(*arg, **kw) return config
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" session_factory = SignedCookieSessionFactory("fishtest") config = Configurator( settings=settings, session_factory=session_factory, root_factory="fishtest.models.RootFactory", ) config.include("pyramid_mako") config.set_default_csrf_options(require_csrf=False) def static_full_path(static_path): return Path(__file__).parent / f"static/{static_path}" def file_hash(file): return base64.b64encode(hashlib.sha384( file.read_bytes()).digest()).decode("utf8") # hash calculated by browser for sub-resource integrity checks: # https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity cache_busters = { f"{i}/{j.name}": file_hash(j) for i in ("css", "js") for j in static_full_path(i).glob(f"*.{i}") } rundb = RunDb() def add_rundb(event): event.request.rundb = rundb event.request.userdb = rundb.userdb event.request.actiondb = rundb.actiondb def add_renderer_globals(event): event["h"] = helpers event["cache_busters"] = cache_busters config.add_subscriber(add_rundb, NewRequest) config.add_subscriber(add_renderer_globals, BeforeRender) # Authentication def group_finder(username, request): return request.userdb.get_user_groups(username) secret = Path("~/fishtest.secret").expanduser().read_text() config.set_authentication_policy( AuthTktAuthenticationPolicy(secret, callback=group_finder, hashalg="sha512", http_only=True)) config.set_authorization_policy(ACLAuthorizationPolicy()) config.add_static_view("css", "static/css", cache_max_age=3600) config.add_static_view("js", "static/js", cache_max_age=3600) config.add_static_view("img", "static/img", cache_max_age=3600) config.add_route("home", "/") config.add_route("login", "/login") config.add_route("nn_upload", "/upload") config.add_route("logout", "/logout") config.add_route("signup", "/signup") config.add_route("user", "/user/{username}") config.add_route("profile", "/user") config.add_route("pending", "/pending") config.add_route("users", "/users") config.add_route("users_monthly", "/users/monthly") config.add_route("actions", "/actions") config.add_route("nns", "/nns") config.add_route("sprt_calc", "/sprt_calc") config.add_route("tests", "/tests") config.add_route("tests_finished", "/tests/finished") config.add_route("tests_run", "/tests/run") config.add_route("tests_view", "/tests/view/{id}") config.add_route("tests_user", "/tests/user/{username}") config.add_route("tests_stats", "/tests/stats/{id}") config.add_route("tests_live_elo", "/tests/live_elo/{id}") # Tests - actions config.add_route("tests_modify", "/tests/modify") config.add_route("tests_delete", "/tests/delete") config.add_route("tests_stop", "/tests/stop") config.add_route("tests_approve", "/tests/approve") config.add_route("tests_purge", "/tests/purge") # API config.add_route("api_request_task", "/api/request_task") config.add_route("api_update_task", "/api/update_task") config.add_route("api_failed_task", "/api/failed_task") config.add_route("api_stop_run", "/api/stop_run") config.add_route("api_request_version", "/api/request_version") config.add_route("api_beat", "/api/beat") config.add_route("api_request_spsa", "/api/request_spsa") config.add_route("api_active_runs", "/api/active_runs") config.add_route("api_get_run", "/api/get_run/{id}") config.add_route("api_get_task", "/api/get_task/{id}/{task_id}") config.add_route("api_upload_pgn", "/api/upload_pgn") config.add_route("api_download_pgn", "/api/pgn/{id}") config.add_route("api_download_pgn_100", "/api/pgn_100/{skip}") config.add_route("api_download_nn", "/api/nn/{id}") config.add_route("api_get_elo", "/api/get_elo/{id}") config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """pserve entry point""" session_factory = UnencryptedCookieSessionFactoryConfig('seekrit!') config = Configurator(settings=settings, session_factory=session_factory) config.include('pyramid_chameleon') deform.renderer.configure_zpt_renderer() config.add_static_view('static_deform', 'deform:static') config.add_route('mini_example', path='/') config.add_view(mini_example, route_name="mini_example", renderer="templates/mini.pt") return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings) config.add_static_view('static', 'static', cache_max_age=3600) # todo config.add_route('home', '/') config.add_route('todo_index', '/todos') config.add_route('todo_create', '/todos/create') config.add_route('todo_update', '/todos/{id}/update') config.add_route('todo_delete', '/todos/{id}/update') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): settings.update(parse_settings(settings)) config = Configurator(settings=settings) config.include("cornice") config.scan() config.add_renderer("xml", XMLRenderer) config.add_renderer("text", PlainTextRenderer) mongo = adapters.MongoDB(settings["kernel.app.mongodb.dsn"]) Session = adapters.Session.partial(mongo) config.add_request_method(lambda request: services.get_handlers(Session), "services", reify=True) return config.make_wsgi_app()
from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import FileResponse from pyramid.view import view_config import my_barcode @view_config(route_name='barcode', renderer='templates/barcode.jinja2') def barcode(request): return [] @view_config(route_name='barcode', request_method='POST') def post(request): nr_eans = my_barcode.upload_to_tuple(request.POST['file'].file) eans = my_barcode.create_eans(nr_eans) myzip = my_barcode.create_zipfile(eans) return FileResponse(myzip, content_type='application/zip') if __name__ == '__main__': with Configurator() as config: config.include('pyramid_jinja2') config.add_route('barcode', '/') config.scan() app = config.make_wsgi_app() server = make_server('0.0.0.0', 8080, app) server.serve_forever()
def main(global_config, **settings): config = Configurator(root_factory=Root, settings=settings) config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.include('.security') config.add_static_view('deform_static', 'deform:static/') config.scan() return config.make_wsgi_app()
print(self.payload['pusher']) # do busy work... return "nothing to push payload" # or simple {} @view_config(header="X-Github-Event:pull_request") def payload_pull_request(self): """This method is a continuation of PayloadView process, triggered if header HTTP-X-Github-Event type is Pull Request""" # {u'name': u'marioidival', u'email': u'*****@*****.**'} print(self.payload['pusher']) # do busy work... return "nothing to pull request payload" # or simple {} @view_config(header="X-Github-Event:ping") def payload_push_ping(self): """This method is responding to a webhook ping""" return {'ping': True} if __name__ == "__main__": config = Configurator() config.add_route("github_payload", "/github_payload/") config.scan() app = config.make_wsgi_app() server = make_server("0.0.0.0", 8888, app) server.serve_forever()
def main(global_config, **settings): """ This function returns the Pyramid WSGI application. """ config = Configurator(settings=settings) # http://docs.pylonsproject.org/projects/pyramid_exclog/dev/api.html#pyramid_exclog.includeme config.include('pyramid_exclog') # https://docs.pylonsproject.org/projects/pyramid_jinja2/dev/api.html#pyramid_jinja2.includeme config.include('pyramid_jinja2') config.get_jinja2_environment().filters.update({ 'date_format': import_string('tumblrproxy.lib.template_filter.date_format'), 'tumblr_video': import_string('tumblrproxy.lib.tumblr_filter.video_embed') }) # view handler config.include('tumblrproxy.controllers.blog') # jinja2 configuration config.add_jinja2_search_path("tumblrproxy:templates") # static content route config.add_static_view('static', 'static', cache_max_age=3600) return config.make_wsgi_app()
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" import mist.api.auth.middleware settings = {} configurator = Configurator(root_factory=Root, settings=settings) configurator.include('pyramid_chameleon') # Add custom adapter to the JSON renderer to avoid serialization errors json_renderer = JSON() def string_adapter(obj, request): return str(obj) json_renderer.add_adapter(object, string_adapter) configurator.add_renderer('json', json_renderer) # Add CSV renderer configurator.add_renderer('csv', 'mist.api.renderers.CSVRenderer') configurator.add_static_view('docs', path='../../../docs/build') # FIXME this should not be necessary social_auth_keys = {key: getattr(config, key, '') for key in ('SOCIAL_AUTH_GOOGLE_OAUTH2_KEY', 'SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET', 'SOCIAL_AUTH_GITHUB_KEY', 'SOCIAL_AUTH_GITHUB_SECRET', 'SOCIAL_AUTH_INTRALOT_OAUTH2_KEY', 'SOCIAL_AUTH_INTRALOT_OAUTH2_SECRET')} configurator.registry.settings.update(social_auth_keys) configurator.registry.settings.update(getattr(config, 'SOCIAL_AUTH_SETTINGS', {})) # /FIXME configurator.include(add_routes) configurator.scan(ignore=['mist.api.sock', 'mist.api.sockjs_mux']) for plugin in config.PLUGINS: log.info("Loading plugin mist.%s", plugin) configurator.include('mist.%s.add_routes' % plugin) ignore_modules = ['mist.%s.sock' % plugin, 'mist.%s.handler' % plugin] configurator.scan('mist.%s' % plugin, ignore=ignore_modules) app = mist.api.auth.middleware.AuthMiddleware( mist.api.auth.middleware.CsrfMiddleware( configurator.make_wsgi_app() ) ) for plugin in config.PLUGINS: try: module = importlib.import_module('mist.%s.middleware' % plugin) for middleware in module.CHAIN: app = middleware(app) except ImportError: pass return app
from pyramid.config import Configurator from pyramid.response import Response def hello_world(request): return Response('Hello world!') def goodbye_world(request): return Response('Goodbye world!') config = Configurator() config.add_view(hello_world) config.add_view(goodbye_world, name='goodbye') app = config.make_wsgi_app()
def mkapp(*args, **kwargs): if config.devel_memory_profile: launch_memory_usage_server() with Configurator(debug_logger=log) as ctx: ctx.add_subscriber(add_cors_headers_response_callback, NewRequest) if config.aliases is None: config.aliases = dict() if config.modules is None: config.modules = [] ctx.registry.config = config config.modules.append('pyff.builtins') for mn in config.modules: importlib.import_module(mn) pipeline = args if not len(pipeline) > 0: pipeline = [config.pipeline] ctx.registry.scheduler = make_default_scheduler() ctx.registry.pipeline = pipeline ctx.registry.plumbings = [plumbing(v) for v in pipeline] ctx.registry.aliases = config.aliases ctx.registry.md = MDRepository() ctx.registry.md.store = make_store_instance(scheduler=ctx.registry.scheduler) log.debug(ctx.registry.md.store) ctx.add_route('robots', '/robots.txt') ctx.add_view(robots_handler, route_name='robots') ctx.add_route('webfinger', '/.well-known/webfinger', request_method='GET') ctx.add_view(webfinger_handler, route_name='webfinger') ctx.add_route('search', '/api/search', request_method='GET') ctx.add_view(search_handler, route_name='search') ctx.add_route('status', '/api/status', request_method='GET') ctx.add_view(status_handler, route_name='status') ctx.add_route('resources', '/api/resources', request_method='GET') ctx.add_view(resources_handler, route_name='resources') ctx.add_route('pipeline', '/api/pipeline', request_method='GET') ctx.add_view(pipeline_handler, route_name='pipeline') ctx.add_route('call', '/api/call/{entry}', request_method=['POST', 'PUT']) ctx.add_view(process_handler, route_name='call') ctx.add_route('request', '/*path', request_method='GET') ctx.add_view(process_handler, route_name='request') start = datetime.utcnow()+timedelta(seconds=1) log.debug(start) if config.update_frequency > 0: ctx.registry.scheduler.add_job(call, 'interval', id="call/update", args=['update'], start_date=start, seconds=config.update_frequency, max_instances=1) ctx.registry.scheduler.start() return ctx.make_wsgi_app()
def test_unit__bind__err__not_implemented(self): controller = Controller() configurator = Configurator() with pytest.raises(NotImplementedError): controller.bind(configurator)
def bind(self, configurator: Configurator) -> None: """ Create all routes and views using pyramid configurator for this controller """ # Workspaces configurator.add_route("workspaces", "/workspaces", request_method="GET") configurator.add_view(self.workspaces, route_name="workspaces") # Workspace configurator.add_route("workspace", "/workspaces/{workspace_id}", request_method="GET") configurator.add_view(self.workspace, route_name="workspace") # Workspace space configurator.add_route("workspace_disk_space", "/workspaces/{workspace_id}/disk_space", request_method="GET") configurator.add_view(self.workspace_disk_space, route_name="workspace_disk_space") # Create workspace configurator.add_route("create_workspace", "/workspaces", request_method="POST") configurator.add_view(self.create_workspace, route_name="create_workspace") # Delete/Undelete workpace configurator.add_route("delete_workspace", "/workspaces/{workspace_id}/trashed", request_method="PUT") configurator.add_view(self.delete_workspace, route_name="delete_workspace") configurator.add_route("undelete_workspace", "/workspaces/{workspace_id}/trashed/restore", request_method="PUT") configurator.add_view(self.undelete_workspace, route_name="undelete_workspace") # Update Workspace configurator.add_route("update_workspace", "/workspaces/{workspace_id}", request_method="PUT") configurator.add_view(self.update_workspace, route_name="update_workspace") # Workspace Members (Roles) configurator.add_route("workspace_members", "/workspaces/{workspace_id}/members", request_method="GET") configurator.add_view(self.workspaces_members, route_name="workspace_members") # Workspace Members (Role) Individual configurator.add_route( "workspace_member_role", "/workspaces/{workspace_id}/members/{user_id}", request_method="GET", ) configurator.add_view(self.workspaces_member_role, route_name="workspace_member_role") # Update Workspace Members roles configurator.add_route( "update_workspace_member", "/workspaces/{workspace_id}/members/{user_id}", request_method="PUT", ) configurator.add_view(self.update_workspaces_members_role, route_name="update_workspace_member") # Create Workspace Members roles configurator.add_route("create_workspace_member", "/workspaces/{workspace_id}/members", request_method="POST") configurator.add_view(self.create_workspaces_members_role, route_name="create_workspace_member") # Delete Workspace Members roles configurator.add_route( "delete_workspace_member", "/workspaces/{workspace_id}/members/{user_id}", request_method="DELETE", ) configurator.add_view(self.delete_workspaces_members_role, route_name="delete_workspace_member") # Workspace Content configurator.add_route("workspace_content", "/workspaces/{workspace_id}/contents", request_method="GET") configurator.add_view(self.workspace_content, route_name="workspace_content") # Create Generic Content configurator.add_route("create_generic_content", "/workspaces/{workspace_id}/contents", request_method="POST") configurator.add_view(self.create_generic_empty_content, route_name="create_generic_content") # Get Content configurator.add_route("get_content", "/contents/{content_id}", request_method="GET") configurator.add_view(self.get_content, route_name="get_content") # Get Content From workspace configurator.add_route( "get_content_from_workspace", "/workspaces/{workspace_id}/contents/{content_id}", request_method="GET", ) configurator.add_view(self.get_content_from_workspace, route_name="get_content_from_workspace") # Move Content configurator.add_route( "move_content", "/workspaces/{workspace_id}/contents/{content_id}/move", request_method="PUT", ) configurator.add_view(self.move_content, route_name="move_content") # Delete/Undelete Content configurator.add_route( "delete_content", "/workspaces/{workspace_id}/contents/{content_id}/trashed", request_method="PUT", ) configurator.add_view(self.delete_content, route_name="delete_content") configurator.add_route( "undelete_content", "/workspaces/{workspace_id}/contents/{content_id}/trashed/restore", request_method="PUT", ) configurator.add_view(self.undelete_content, route_name="undelete_content") # # Archive/Unarchive Content configurator.add_route( "archive_content", "/workspaces/{workspace_id}/contents/{content_id}/archived", request_method="PUT", ) configurator.add_view(self.archive_content, route_name="archive_content") configurator.add_route( "unarchive_content", "/workspaces/{workspace_id}/contents/{content_id}/archived/restore", request_method="PUT", ) configurator.add_view(self.unarchive_content, route_name="unarchive_content") # Subscriptions configurator.add_route( "workspace_subscriptions", "/workspaces/{workspace_id}/subscriptions", request_method="GET", ) configurator.add_view(self.workspace_subscriptions, route_name="workspace_subscriptions") configurator.add_route( "accept_subscription", "/workspaces/{workspace_id}/subscriptions/{user_id}/accept", request_method="PUT", ) configurator.add_view(self.accept_subscription, route_name="accept_subscription") configurator.add_route( "reject_subscription", "/workspaces/{workspace_id}/subscriptions/{user_id}/reject", request_method="PUT", ) configurator.add_view(self.reject_subscription, route_name="reject_subscription") # Content path configurator.add_route( "get_content_path", "/workspaces/{workspace_id}/contents/{content_id}/path", request_method="GET", ) configurator.add_view(self.get_content_path, route_name="get_content_path")
def main(global_config, **settings): config = Configurator(settings=settings) init(config) return config.make_wsgi_app()
def main(global_config, config=None, **settings): if not config: config = Configurator(settings=settings, root_factory=RouteFactory) # Force project name, since it determines settings prefix. config.add_settings({'kinto.project_name': 'kinto'}) kinto.core.initialize(config, version=__version__, default_settings=DEFAULT_SETTINGS) settings = config.get_settings() # Expose capability schema_enabled = asbool( settings['experimental_collection_schema_validation']) if schema_enabled: config.add_api_capability( "schema", description="Validates collection records with JSON schemas.", url="https://kinto.readthedocs.io/en/latest/api/1.x/" "collections.html#collection-json-schema") # Scan Kinto views. kwargs = {} flush_enabled = asbool(settings['flush_endpoint_enabled']) if flush_enabled: config.add_api_capability( "flush_endpoint", description="The __flush__ endpoint can be used to remove all " "data from all backends.", url="https://kinto.readthedocs.io/en/latest/configuration/" "settings.html#activating-the-flush-endpoint") else: kwargs['ignore'] = ['kinto.views.flush'] # Permissions endpoint enabled if permission backend is setup. permissions_endpoint_enabled = (asbool( settings['experimental_permissions_endpoint']) and hasattr(config.registry, 'permission')) if permissions_endpoint_enabled: config.add_api_capability( "permissions_endpoint", description="The permissions endpoint can be used to list all " "user objects permissions.", url="https://kinto.readthedocs.io/en/latest/configuration/" "settings.html#activating-the-permissions-endpoint") else: kwargs.setdefault('ignore', []).append('kinto.views.permissions') config.scan("kinto.views", **kwargs) app = config.make_wsgi_app() # Install middleware (no-op if disabled) return kinto.core.install_middlewares(app, settings)
def app(): from webtest import TestApp settings = dict() settings['error.err_response'] = exception.json_error_response settings['error.exc_response'] = exception.json_error_response config = Configurator(settings=settings) config.include(exception) def view_error(request): raise ErrorTest() config.add_route('error', '/error') config.add_view(view_error, route_name='error') def view_exception(request): raise ExceptionTest() config.add_route('exception', '/exception') config.add_view(view_exception, route_name='exception') def view_json(request): request.json request.json_body return Response('OK', status_code=200) config.add_route('json', '/json') config.add_view(view_json, route_name='json') yield TestApp(config.make_wsgi_app())
def main(global_config, **settings): config = Configurator(settings=settings) db_url = urlparse(settings['mongo_uri']) config.registry.db = MongoClient( host=db_url.hostname, port=db_url.port, ) def add_db(request): db = config.registry.db[db_url.path[1:]] if db_url.username and db_url.password: db.authenticate(db_url.username, db_url.password) return db config.add_request_method(add_db, 'db', reify=True) config.include('pyramid_chameleon') config.add_route('home', '/') config.add_route('add', '/add') config.add_route('rank', '/rank') config.add_static_view(name='static', path='PyTube:static') config.scan('.views') return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine init_model() session_factory = session_factory_from_settings(settings) if 'localization' not in settings: settings['localization'] = 'id_ID.UTF-8' locale.setlocale(locale.LC_ALL, settings['localization']) if 'timezone' not in settings: settings['timezone'] = DefaultTimeZone config = Configurator(settings=settings, root_factory='inventory.models.RootFactory', session_factory=session_factory) config.include('pyramid_beaker') config.include('pyramid_chameleon') authn_policy = AuthTktAuthenticationPolicy('sosecret', callback=group_finder, hashalg='sha512') authz_policy = ACLAuthorizationPolicy() config.set_authentication_policy(authn_policy) config.set_authorization_policy(authz_policy) config.add_request_method(get_user, 'user', reify=True) config.add_request_method(get_title, 'title', reify=True) config.add_notfound_view(RemoveSlashNotFoundViewFactory()) config.add_static_view('static', 'static', cache_max_age=3600) config.add_static_view('deform_static', 'deform:static') config.add_static_view('files', settings['static_files']) routes = DBSession.query(Route.kode, Route.path, Route.nama).all() for route in routes: config.add_route(route.kode, route.path) if route.nama: titles[route.kode] = ' - '.join([main_title, route.nama]) config.scan() app = config.make_wsgi_app() from paste.translogger import TransLogger app = TransLogger(app, setup_console_handler=False) return app
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine authn_policy = AuthTktAuthenticationPolicy('auth.secret', callback=groupfinder) authz_policy = ACLAuthorizationPolicy() config = Configurator(settings=settings, authentication_policy=authn_policy, authorization_policy=authz_policy, root_factory=RootFactory, ) config.include('pyramid_mako') config.add_route('home', '/') config.add_route('login', '/login') config.add_route('logout', '/logout') config.add_route('users', '/users', factory=UserFactory) config.add_route('user', '/user/{login}', factory=UserFactory, traverse='/{login}') config.add_route('pages', '/pages', factory=PageFactory) config.add_route('create_page', '/create_page', factory=PageFactory) config.add_route('page', '/page/{title}', factory=PageFactory, traverse='/{title}') config.add_route('edit_page', '/page/{title}/edit', factory=PageFactory, traverse='/{title}') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings) authentication_policy = AuthTktAuthenticationPolicy( secret=settings['auth.secret'], ##callback=group_finder, hashalg=settings.get('auth.hash-algorithm', 'sha512'), ) config.set_authentication_policy(authentication_policy) authorization_policy = ACLAuthorizationPolicy() config.set_authorization_policy(authorization_policy) # Route registration config.include(register_bbb) config.include(register_api, route_prefix='/api') config.include(set_up_velruse) config.include(set_up_service_exchange) config.include(register_www_iface) config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_chameleon') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('ups_view', '/{ups}') config.add_view('webnut.views.notfound', renderer='webnut:templates/404.pt', context='pyramid.exceptions.NotFound') config.scan() return config.make_wsgi_app()