I have a controller method that needs to return json if its an ajax request 
(from jquery get,post,ajax) or return a template.

    @expose('json')
    @expose('erp.templates.search.customer')
    def customer(self,query,came_from,search_type):
        log.debug("(%s) %s"%(search_type,query))
        if search_type == 'query':
            pass
        elif search_type == 'by_id':
            customer = m_ar.Customer.by_code(query)
            override_template(Search.customer,'json:')
            return {'customer_id':customer.customer_id}
        return dict(customers = customers)

This doesn't work. I am not sure i need the override but without it the 
actual genshi template is returned. Without i get errors about identity not 
being able to translate into json.

How should I best go about this? I could split this into two methods search 
at call time i know if its json i want or the template however i am still 
curious about how this could work.

PK

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/turbogears/-/XvS0ssADkqUJ.
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