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 django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to