Diez B. Roggisch schrieb:
> I wonder: how does rules detect that? Through an algebraic analysis?
Yes, it analyzes the rules to check which one is more specific.
> @jsonify.modelobject(clazz)
>
> that would render the proper signature.
Good idea. TurboJson could define the following decorator:
def when_sqlobject(classinfo=None):
if classinfo:
cond = isinstance(classinfo, str) and classinfo or 'classinfo'
cond = "isinstance(obj, %s) and " % cond
else:
cond = ""
cond += "is_sqlobject(obj) and not hasattr(obj, '__json__')"
return jsonify.when(cond)
Works perfectly well for me.
But I just see that Alberto and Jonathan already solved this problem for
TurboJson 1.2 by using prioritized_methods (see discussion here:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg05140.html).
The idea here is letting the json.py rules always have higher priority
than the rules that are defined by default. I think this makes sense.
However, we cannot use prioritized_methods for TJ < 1.2 since it does
not work with RuleDispatch. But we could use something similar,
turbogears.genericfunctions.MultiorderGenericFunction. The only problem
is that I would not like to create the reverse depency of TJ from TG,
and the order parameter is called "order" instead of "prio", and works
the other way round. So maybe we could integrate a modified
MultiorderGenericFunction with a prio parameter into TJ 1.1. Then we
would be fully compatible with TJ 1.2 in this regard.
-- Christoph
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---