Jani, Not sure what you are trying to achieve. Wolfram suggested below solution to me a while ago and I'm happy with it.
Rob On Apr 6, 2009, at 3:14 AM, Jani Tiainen wrote: > > I've been trying to find out nice solution to handle JSON-RPC with > Django and Dojo (Dojango). > > So far not much avail. Has anyone succeeded with this? Care to share > what kind of packages do I need to make it working with preferably > automated SMD generations. > > -- > Jani Tiainen > > > > > On Nov 2, 2008, at 12:42 AM, Wolfram Kriesing wrote: > >> >> awesome :-) >> Glad I could help. >> Feel free to ask anything, I will try to help! >> >> -- >> cu >> >> Wolfram >> >> http://uxebu.com - web consultancy >> You need AJAX, RIA, JavaScript and all this modern stuff? We got it! >> >> >> >> On Sun, Nov 2, 2008 at 1:14 AM, Rob Goedman <[email protected]> wrote: >>> >>> Wolfram, >>> >>> You bet I've read your blogs! Wouldn't have gotten where I got to >>> without them! >>> >>> Clearly I had missed the to_dojo_data(), that's exactly what I was >>> looking for. >>> >>> This works super. >>> >>> Thanks a lot, >>> Rob >>> >>> On Nov 1, 2008, at 4:45 PM, Wolfram Kriesing wrote: >>> >>>> >>>> Hi Rob, >>>> >>>> aehm, maybe what you were looking for was this: >>>> >>>> @json_response >>>> def send_toxids_list(request): >>>> ret = Toxid.objects.all() >>>> return to_dojo_data(ret, identifier='docno') >>>> >>>> the json_response decorator takes care of extrcting only the >>>> fields form the model, you dont have to do this >>>> by hand. And the to_dojo_data() function converts the >>>> data into a dojo.data store compatible format. >>>> >>>> See also this blog post about more info >>>> about the json_response decorator/function >>>> and insight details. >>>> http://wolfram.kriesing.de/blog/index.php/2007/json-serialization-for-django >>>> >>>> >>>> -- >>>> cu >>>> >>>> Wolfram >>>> >>>> http://uxebu.com - the AJAX experts >>>> You need AJAX, RIA, JavaScript and all this modern stuff? We got >>>> it! >>> >>> >>>> On Nov 1, 2008, at 4:34 PM, Wolfram Kriesing wrote: >>>>> >>>>> Hi Rob, >>>>> >>>>> did you see the blog article >>>>> http://blog.uxebu.com/2008/07/26/ajax-with-dojango/ >>>>> and the examples in >>>>> http://code.google.com/p/dojango/source/browse/trunk/dojango/views.py >>>>> >>>>> tbh I don't really understand what you are using the JSON >>>>> serializer for. >>>>> Could you may be explain, if the links above dont help? >>>>> >>>>> -- >>>>> cu >>>>> >>>>> Wolfram >>>>> >>>>> http://uxebu.com - the AJAX experts >>>>> You need AJAX, RIA, JavaScript and all this modern stuff? We got >>>>> it! >>> >>> >>>>> On Sat, Nov 1, 2008 at 11:31 PM, Rob Goedman <[email protected]> >>>>> wrote: >>>>> >>>>> Hi, >>>>> >>>>> Just for Django & Dojo users. >>>>> >>>>> Working through the 'Mastering Dojo' book, updating the examples >>>>> where >>>>> applicable to Dojo 1.2 (i.e. grids) and making them work with >>>>> Django >>>>> svn has gone pretty smoothly. I wonder if below method is a >>>>> reasonable >>>>> way to generate fairly generic xhr* responses? >>>>> >>>>> I use something like (e.g. from the dojo.data chapter on >>>>> QueryReadStore): >>>>> >>>>> @json_response >>>>> def send_toxids_list(request): >>>>> """ >>>>> Creates a JSON/Dojo hash with the filtered contents >>>>> for a grid. This method is called by Dojo xhr*. >>>>> >>>>> To do: >>>>> >>>>> 1) Change ...all() into ...filter() >>>>> according to qDict info. >>>>> >>>>> """ >>>>> >>>>> qDict = request.GET >>>>> print qDict['user'], qDict.get('query', None) >>>>> >>>>> queryset = Toxid.objects.all() >>>>> json_serializer = serializers.get_serializer("json")() >>>>> toxids_json = json_serializer.serialize(queryset, >>>>> ensure_ascii=True) >>>>> t = eval(toxids_json) >>>>> a = [] >>>>> for i in t: a.append(i['fields']) >>>>> ret = { >>>>> "identifier": "docno", >>>>> "label": "substance", >>>>> "items": a, >>>>> } >>>>> return ret >>>>> >>>>> It seems a frequently recurring pattern in my views, so I would >>>>> like >>>>> to do it right and efficient. Particularly the 'eval' step feels >>>>> weird. >>>>> >>>>> I did have a look at dojox.dtl (Django Templating Language) but >>>>> haven't (yet?) figured out if that is applicable for this. >>>>> >>>>> Thanks, >>>>> Rob >>>>> >>>>> >>>>> >>>>>> >>>>> >>>> >>>>> >>> >>> >>>> >>> >> >> --~--~---------~--~----~------------~-------~--~----~ >> You received this message because you are subscribed to the Google >> Groups "Django users" 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/django-users?hl=en >> -~----------~----~----~----~------~----~------~--~--- >> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" 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/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

