On Thu, Jan 15, 2009 at 1:10 PM, mk <[email protected]> wrote: > > Gael Pasgrimaud wrote: > >> _py_object is not defined at this this. __init__ is a special case. >> You can only use @jsonify on a controller action. >> >> Try: >> >> class JsonController(BaseController): >> >> @jsonify >> def data(self): >> return {'test':'values'} >> >
This work if you call the url http://localhost/data Again, this decorator can *only* be used on a controller **action** > It still doesn't work: > > > from helloworld.lib.base import BaseController > > import pylons.decorators > > class JsonIt(BaseController): > > @pylons.decorators.jsonify > def data(self): > return {'abc':123} > > > I call it like that in controller: > > def jsontest3(self): > return helloworld.lib.projlib.JsonIt().data() > Then don't use a decorator... >>> import simplejson >>> simplejson.dumps(dict(test=1)) '{"test": 1}' > > Again, the error msg is "AttributeError: 'JsonIt' object has no > attribute '_py_object'" > > Regards, > mk > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
