On 11/07/2012 04:27 PM, tankerdude wrote:
It's a pretty trivial application to start.
Here's the __init__.py file that goes with it. It's from the
appengine_pyramid scaffold and that I just added a few lines to. And
yes, I can't see it either. I've done all the way down into router.py's
handle_request method.
Fails to find a view_callable here:
# 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
importos
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'}
Move testMe function above the "application = make_app()" line. This is
just garden-variety Python behavior.
- c
On Wednesday, November 7, 2012 12:48:21 PM UTC-8, Chris McDonough wrote:
On 11/07/2012 03:36 PM, tankerdude wrote:
> This will work...
>
> 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?
I see nothing wrong with it, but you're not really pasting your actual
app, just some pseudocode.
- C
--
You received this message because you are subscribed to the Google
Groups "pylons-devel" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pylons-devel/-/x-h48vhymSgJ.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/pylons-devel?hl=en.
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/pylons-devel?hl=en.