On 6 March 2013 15:23, Whit Morriss <[email protected]> wrote: > you probably can choose where your users might write code. per > suggestion above, maybe overriding __getitem__ isn't the best way for you? >
I want my users to make their own pyramid resources, like any user of pyramid might. Plain old resources, which act and behave as any plain-old resource might. Then I want my code to "just work" with it. do you have code or pseudo code you can share? It might help understand > exactly whether the issue is something that can be more simply handled a > different way or whether you are trying something legitimately not easy to > do with the framework as it is. I'm guessing there is an easier/simpler > way, but it's hard to be sure with more concrete examples of what you want > to do. > Sorry, the code is awful and I don't think it's much use for the discussion, but here it is anyway. I want to know how to write this for-loop. The purpose is that it traverses many objects in one go. The problem is what to do with KeyErrors, since I don't know if they came from `context[key]` because the key is unavailable or from some function call inside context.__getitem__ which is actually an error. And if there is actually an error, I have nowhere to propagate it since the default traverser will catch it. https://github.com/rootpy/WebOOT/blob/master/weboot/resources/multitraverser.py#L427 As Chris McDonough points out, I can write my own traverser. I'll give that a shot at some point. Is the best thing to copy-paste the whole ResourceTreeTraverser yank the KeyError except clause, or does anyone have any brighter ideas? (found here) https://github.com/Pylons/pyramid/blob/master/pyramid/traversal.py#L619 -- I do still believe that the architecture is problematic and hides errors for everyone, it's just painfully obvious in my case. It's currently a landmine sitting in there for any users of mine. It's clear to me that it's a ridiculously big ask to suggest that Pyramid's architecture be changed, since such a change would cause a lot of conceptual and literal breakage. It's still worth having this in mind though. I'm not sure all possibilities have been explored. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
