There currently isn't a way to do this, but I have tentative plans to
make something like this happen -- at least for tg2.

Pretty much all we need is a buffet rendering engine which takes the
dict and just passes it right on.

@expose('python') could then be updated to return python when there's
a format='python' parameter in the request -- or, if exposing things
to python ought to always standard, we could drop the need to regester
the 'python' engine... )

Ultimately it might be that this little engine shoudl be bundled up
with the JSON engine, and a couple other proposed engines that don't
require dictionaries (amf3 is one example).

--Mark Ramm

On 11/2/07, g <[EMAIL PROTECTED]> wrote:
>
> Is there a way to return json values when a controller function is
> called from an http request and return native python values when the
> function is called from within another controller function?
> Basically, this is what I want to do:
>
> @expose(allow_json=True)
> def func1(self, **kwargs):
>     ...
>    return dict(key1=val1, key2=val2)
>
> def func2(self, **kwargs):
>    ...
>    result = func1(tg_format='plain', arg1=val1)
>
> So, when func1() is called via an http request (with
> tg_format='json'), it will return json, and when it's called from
> func2(), it will return a python dictionary.
>
>
> >
>


-- 
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

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