Here's a tutorial I did a couple of years ago:


http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/humans/resources/index.html

I happen to be updating it at the moment in another tutorial, to be released later. But the material and the explanation are generally still accurate.

It is very shallow and might not match what you are doing (e.g. ZODB) but if you can get through it with a good understanding of what is presented, you'll be in good shape. And you'll have a basic example working. :)

--Paul

On 9/4/13 8:18 PM, Chung WONG wrote:
Hi all,

I have read all the docs available on pyramid's website, however I still
don't really understand how to get a basic traversal app working.
The hello world example is good but I am not able to extend it. The ZODB
wiki is good too but it is a bit too much information to me with auth and
zodb.
What I am trying to do is to add some views to the hello world example but
my understanding is very vague.
I created a starter scaffolding.

# __init__.py
from pyramid.config import Configurator
*from pyramid.response import Response*

*class Resource(dict):*
*    pass*
*
*
*def get_root(request):*
*    return
Resource({'a':Resource({'b':Resource({'c':Resource({'c':Resource()})})})})*
*
*
*def hello_world_of_resources(context,request):*
*    output="Here's a resource and its children: %s" % content*
*    return Response(output)*

def main(global_config, **settings):
     """ This function returns a Pyramid WSGI application.
     """
     config = Configurator(settings=settings,root_factory=get_root)
     config.add_static_view('static', 'static', cache_max_age=3600)
*    config.add_view(hello_world_of_resources,context=Resource)*
     config.scan()
     return config.make_wsgi_app()


#views.py
from pyramid.view import view_config
*from pyramid.response import Response*

*@view_config()*
*def my_login(request):*
*    return Response('login')*
*
*
*@view_config()*
*def my_logout(request):*
*    return Response('logout')*

I have no clue how to link the resource with the views. Did I miss
something import in the docs or are there any very basic/bare minimum
traversal only tutorial?
Thanks in advance.


--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to