Thanks for the info. I'm following up on the idea of using
request.subpath, but at what point does this property get created?
This is my understanding of the call stack:

1. the RootFactory is called, with the request object as a parameter
2. the RootFactory returns the root resource
3. Pyramid recursively calls the __getitem__ method on the resource
until it runs out of parts or a resource returns a KeyError
4. ...
5. a view gets called with the request and context

How do I access the request object from within the __getitem__ method
of my resources? If I'm to dynamically return resource objects based
on the subpath, then I need to somehow access the request object at
that point

Currently I'm storing the request object I got in step 1 it inside my
RootFactory

root_factory.request = request

and every resource object is constructed with

Resource.__name__
Resource.__parent__
Resource.root_factory = root_factory

Which allows me to access the request object from inside the
__getitem__ method, but I get an attribute error that request.subpath
doesn't exist. Does it only get created later?

I'm guessing that for the archive object to be the valid context and a
view to be called, it should raise a KeyError  during traversal, but
if I do this, I just get a 404 error without getting a view called
that would be able to access the request.subpath property.

Sorry if I'm creating more confusion on the subject.

oO


On Jan 30, 6:04 am, Wade Leftwich <wleftw...@gmail.com> wrote:
> If you want to stick with Traversal, don't forget that you have
> request.subpath available to you. For the path "/blog/archive/
> 2011/01/29/my-post-about-pyramid", you could have an Archive context
> whose default (unnamed) view  would be called with a request that
> included request.subpath = ['2011', '01', '29', 'my-post-about-
> pyramid'].

-- 
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.

Reply via email to