1 from django.views.generic.base import TemplateView
2 from django.shortcuts import render_to_response
4 from unfold.loginrequired import LoginRequiredView
5 from django.http import HttpResponse
7 from manifold.core.query import Query, AnalyzedQuery
8 from manifoldapi.manifoldapi import execute_query
10 from rest import ObjectRequest, error, success
12 from string import join
17 def dispatch(request, object_type, object_name):
19 o = ObjectRequest(request, object_type, object_name)
21 if request.method == 'POST':
22 req_items = request.POST
23 elif request.method == 'GET':
24 #return error('only post request is supported')
25 req_items = request.GET
27 for el in req_items.items():
28 # Filters not used for create
29 if el[0].startswith('filters'):
30 o.filters[el[0][8:-1]] = el[1]
31 elif el[0].startswith('params'):
32 #o.params[el[0][7:-1]] = el[1]
33 o.params.append({el[0][7:-1]:el[1]})
34 elif el[0].startswith('fields'):
35 o.fields=req_items.getlist('fields[]')
36 elif el[0].startswith('options'):
37 o.options = req_items.getlist('options[]')
43 return success('record created')
45 return error('an error has occurred')