Hi,
I'm new to python and pyramid. I am currently trying to get traversal
working. I started with
the "pyramid_starter" project template. Currently there is the default
view generated by the
template and a Welcome view I created. Question at bottom of post.
The views.py module:
#########
from pyramid.response import Response
def my_view(request):
return {'project':'test'}
def welcome(request):
return Response("Welcome")
#######
My resource tree is generated in the resources.py module:
#######
class Resource(dict):
pass
root = Resource({'Welcome': Resource()})
def get_root(request):
return root
#######
and the views are configured in the __init__ module as:
#######
from pyramid.config import Configurator
from test.resources import get_root, Resource
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=get_root, settings=settings)
config.add_view('test.views.my_view',
context='test.Resource',
renderer='test:templates/mytemplate.pt')
config.add_view('test.views.welcome',
context='test:resources.Resource',
renderer='welcome.mak')
config.add_static_view('static', 'test:static')
return config.make_wsgi_app()
######
I am having issues with the context of the welcome view configuration.
As you can see it is
defined as context='test:resources.Resource' which is the same as
my_view.
I realise that the context must somehow reference the Welcome resource
in the resource tree.
However, I cannot use something like test:resources.Resource.Welcome
as Welcome is not
a member of the Resource class.
Can somebody point out what I should do get this simple case working.
I am having difficulties
in constructing a proper and well defined resource tree. Maybe I don't
quite fully comprehend the
concept of a context.
Thanks
Burak
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.