From c0b3bdd29cbb80095ac8eccc86656344e24f6358 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 25 Jan 2010 20:27:10 +0530 Subject: [PATCH] make new api work --- oxdb/backend/daemon.py | 4 ++-- oxdb/backend/managers.py | 5 +++++ oxdb/backend/views.py | 7 ++++--- oxdb/urls.py | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/oxdb/backend/daemon.py b/oxdb/backend/daemon.py index c7ea289..1bc60f0 100644 --- a/oxdb/backend/daemon.py +++ b/oxdb/backend/daemon.py @@ -25,8 +25,8 @@ def run(): imdbId = data['loadIMDb'] load.loadIMDb(imdbId) elif 'findMovie' in data: - f = models.File.objects.get(pk=data['findMovie']) - f.findMovie() + f = models.File.objects.get(pk=data['findMovie']) + f.findMovie() message.ack() consumer.register_callback(handle_background_tasks_callback) consumer.wait() # Go into the consumer loop. diff --git a/oxdb/backend/managers.py b/oxdb/backend/managers.py index eb32a99..3227910 100644 --- a/oxdb/backend/managers.py +++ b/oxdb/backend/managers.py @@ -3,6 +3,7 @@ import re from datetime import datetime from urllib2 import unquote +import json from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist @@ -30,10 +31,14 @@ class MovieManager(Manager): also checks for lists. range and order must be applied later ''' + ''' q = '' for i in request.META['QUERY_STRING'].split('&'): if i.startswith('q='): q = i[2:] + ''' + q = json.loads(request.POST['data'])['q'] + print q op = ',' if '|' in q: op = '|' diff --git a/oxdb/backend/views.py b/oxdb/backend/views.py index 70be73d..c3fe037 100644 --- a/oxdb/backend/views.py +++ b/oxdb/backend/views.py @@ -39,7 +39,8 @@ def api(request): response = f(request) else: response = {'status': 404, 'statusText': 'Unknown function %s' % function} - return render_to_json_response(response) + response = render_to_json_response(response) + return response def api_hello(request): ''' @@ -162,7 +163,7 @@ def _order_query(qs, s, prefix='sort__'): return qs def _parse_query(request): - get = request.GET + get = json.loads(request.POST['data']) query = {} query['i'] = 0 query['o'] = 100 @@ -320,7 +321,7 @@ POST update } ''' #@login_required_json -def api_update(request, archive): +def api_update(request): print "update request" data = json.loads(request.POST['data']) archive = data['archive'] diff --git a/oxdb/urls.py b/oxdb/urls.py index 37056b0..28c4778 100644 --- a/oxdb/urls.py +++ b/oxdb/urls.py @@ -10,7 +10,7 @@ admin.autodiscover() urlpatterns = patterns('', # Example: (r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')), - (r'^api/', include('backend.views.api')), + (r'^api/', 'backend.views.api'), (r'^$', 'app.views.index'), # Uncomment the admin/doc line below and add 'django.contrib.admindocs'