def working_view(request):
return {'result' : 'ok' }
def make_app():
config.add_route('a', '/a', request_method='GET')
config.add_view(working_view, route_name='a', renderer='json')
That will go to /a with the method but now I try to use @view_config that I'ved used when not running in GAE
def make_app():
config.add_route('test', '/test', request_method='GET')
config.scan()
@view_config(route_name='test', renderer='json')
def testMe(request):
return {'result' : 'hello'}
That, for some reason, will not pick up the /test and 404. The view callable isn't correctly registered. Maybe I'm doing something slightly wrong?
Thanks.
# find a view callable
context_iface = providedBy(context)
view_callable = adapters.lookup(
(IViewClassifier, request.request_iface, context_iface),
IView, name=view_name, default=None)
---- Code Snippet---
from pyramid.config import Configurator
from resources import Root
import views
import pyramid_jinja2
import os
import logging
from pyramid.view import view_config
__here__ = os.path.dirname(os.path.abspath(__file__))
def working_view(request):
return {'result' : 'ok' }
def make_app():
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=Root)
config.add_renderer('.jinja2', pyramid_jinja2.Jinja2Renderer)
config.add_view(views.my_view,
context=Root,
renderer='mytemplate.jinja2')
config.add_route('a', '/a', request_method='GET')
config.add_route('test', '/test', request_method='GET')
config.add_view(working_view, route_name='a', renderer='json')
config.add_static_view(name='static',
path=os.path.join(__here__, 'static'))
config.scan()
return config.make_wsgi_app()
application = make_app()
@view_config(route_name='test', renderer='json')
def testMe(request):
return {'result' : 'hello'}