def enchants_json(request): '''エンチャント一覧の json インタフェース''' order = request.GET.get('orderby') if order and request.GET.get('sortorder') == 'descending': order = '-' + order limit = request.GET.get('max-results') if limit: limit = int(limit) else: limit = 50 callback = request.GET.get('callback') cond = {} cond_names = ['name', 'rank', 'root', 'equipment', 'effects'] for name in cond_names: value = request.GET.get(name) if value: cond[name] = value q = EnchantClass.find(order=order, limit=limit, **cond) items = [] for i in q: items.append(to_enchant_map(i)) return HttpResponse(create_feed(items, callback)) # , 'application/json')