On Nov 3, 12:20 pm, "Phillip J. Eby" <[EMAIL PROTECTED]> wrote:
> > Is there some kind of prioritization of dispatch method in case of
> > ambiguous method ?
>
> Add an "and" condition that will be true to the higher-priority
> method.  E.g. "isinstance(x, Foo) and [some condition involving x that
> will be true]".

That doesn't resolve the ambiguous method problem. Here are the three
rules we are talking about:

jsonify_saobject:
"hasattr(obj, 'c') and
isinstance(obj.c,sqlalchemy.util.OrderedProperties)"

jsonify_explicit:
'hasattr(obj, "__json__")'

Before the patch i was using the explicit method. After the patch that
added saobject, the two conditions became true (since my object is a
saobject, and also has a __json__ method) raising an ambiguous method
error.

Now as you suggested (if i understood correctly), I tried the
following: I removed all the __json__ methods, and i added the
following condition to json.py:

"isinstance(obj, projectname.model.User) and hasattr(obj, 'c') and
isinstance(obj.c,sqlalchemy.util.OrderedProperties)"

So i'm just 'extending' the check for saobject with another condition.
But it seems this function is never called and the other one is used
instead. But even then, I don't think having to manually 'extend' like
this the jsonify checks is a Good Thing..

A temporary workaround would be to make saobject check for "not
hasattr('__json__')" so that in case of ambiguity the explicit
jsonification is used..

Raf


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to