Jonathan LaCour wrote:
> Raphael Slinckx wrote:
> 
>> Now, with the upgrade the rule in turbojson is becoming ambiguous with
>> the two previously mentioned rules, meaning i just can't customize
>> sqlalchemy mapped object's jsonification, because either i add a
>> __json__ and dispatch doesn't know whether to use __json__ or the
>> builtin jsonify_saobject (AmbiguousMethod), or I add an explicit rule,
>> but the same error appears.
> 
> I have been having the same problem.  I solved it by doing this before I
> defined my own custom jsonify rules:
> 
>      jsonify.clear()
> 
> This will clear out all of the existing jsonification functions, and
> yours will take precedence.  However, this isn't ideal.  What we really
> need is a way to resolve the AmbiguousMethod issue by somehow making our
> constraints more specific.  I don't know how to do that, however.

Take a look at toscawidgets.genericfunctions (has no dependencies with
TW at all). It has a custom combiner that adds a "priority" argument to
when() (and before(), around() and after()) which greatly simplifies
writing rules since you don't need to make one of them more specific to
resolve ambiguities. For rules having the same priority it behaves in
the same way as the standard combiner.

The tests, at tests/test_genericfunctions.py, might shed a light on how
it's used. It's been serving me well for some time :)

Alberto

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