On Thu, Feb 16, 2012 at 12:09:36PM -0800, Mike Orr wrote:As a side note, you could also use pyramid_traversalwrapper "which wraps each
> I'm weighing whether to use traversal in a limited way, and whether
> the benefits would outweigh the costs.
> I'm converting a Pylons application that has two database-related
> I can use URL dispatch in Pyramid, but then the views have to do the
> Using traversal, the resource tree would take care of fetching the
traversed object in a location-aware proxy", so you don't need to manage
__parent__ and __name__ attributes by yourself, I've found it pretty useful.
> So first, is this the right way to to it?I think it's fine.
> Second, how can I generate URLs to resources without loading the objectsThat's interesting question. I'm thinking of the following construct:
> through this interface? The home page queries the 30 most recent incidents
> and displays links to them. request.resource_url() requires a resource
> object, but the home page or browse pages query the database directly and get
> plain ORM objects rather than location-aware ones. I could make the URLs
> manually but that sucks. I could somehow get the "incident" resource and
> append the ID, or get the root resource and append "incident" and the ID, but
> that's not much better.
1. Make your resource graph lazy, e.g. producing only proxies which only
2. Reuse your resource graph in pyramid's traversal engine and in your home
So you get ``entries`` list of location-aware Entry objects which are loaded
> Creating a traversal path ("/incident/123"), asking for the resource,Why not memoize results of traversing? This kind of caching seems pretty
> and then generating the URL from it (which would be the same
> "/incident/123"), would be equally silly, and would also trigger a
> redundant query.
natural to me.
> And that raises another issue, the "incident" resource doesn't reallyI'm sure it should exist -- it's a container of incidents! Any reasons you
> exist. I.e., "/incident" should return an error, not connect to a
> regular view or default view. How do I do that? Or how do I make the
> default view be "not found"?
don't want to expose it? If yes -- just adapt it to HTTPForbidden or something
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.