On 6 March 2013 10:21, Arndt Droullier <[email protected]> wrote:

> I don't think you need to implement a new traverser you just need to
> provide a
> customized __getitem__ to be used by your users and handle all issues you
> described there.
> For example provide a decorator and introduce a NoRessource Exception and
> to be used
> instead of KeyError.
>

Well, I want the users to write their own resources, and therefore
(potentailly) implement their own __getitem__.


> Though 'MultiTraverser' sounds like you already have replaced the default
> traverser?
>

I was going to say here that I use `pyramid.traversal.traverse`, then I
realised that I do not.

My code currently suffers from the same problem. Because "KeyError" is the
thing used to denote "no such resource", I can't tell the difference
between a non-existing resource and a programmer error. I can't currently
think of a way out of this, without changing pyramid's use of KeyError to
indicate no such resource in general :(. I'm sure this is a sign of bad
design on my part, but it does seem like KeyError to indicate no such
resource is also slightly problematic in general.

I'm a little surprised I'm the first to raise this. Does anyone out there
agree with my point, or is this truly just unique to me? I guess in most
cases people are a) familiar with pyramid and that they have to be careful
not to accidentally raise KeyError, b) if they find themselves in a
no-such-resource situation it's obvious, c) if they find themselves in a
no-such-resource situation they know that they have to check for unexpected
KeyErrors.

Are a)+b)+c) reasonable expectations for all pyramid developers?

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


Reply via email to