Subversion Repositories SmartDukaan

Rev

Rev 14013 | Rev 14015 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14013 Rev 14014
Line 5... Line 5...
5
'''
5
'''
6
from dtr import main
6
from dtr import main
7
from dtr.storage import Mongo
7
from dtr.storage import Mongo
8
import falcon
8
import falcon
9
import json
9
import json
-
 
10
import urlparse
10
class StoreOrder():
11
class StoreOrder():
11
    def on_post(self, req, resp):
12
    def on_post(self, req, resp):
12
        
13
        
13
        try:
14
        try:
14
            string1 = req.stream.read()
15
            string1 = req.stream.read()
Line 43... Line 44...
43
        
44
        
44
class Track():
45
class Track():
45
    def on_post(self, req, resp, userId):
46
    def on_post(self, req, resp, userId):
46
        try:
47
        try:
47
            string1 = req.stream.read()
48
            string1 = req.stream.read()
48
            print string1
49
            req_obj = urlparse.parse_qs(string1)
49
        except ValueError:
50
        except ValueError:
50
            raise falcon.HTTPError(falcon.HTTP_400,
51
            raise falcon.HTTPError(falcon.HTTP_400,
51
                'Malformed JSON',
52
                'Malformed JSON',
52
                'Could not decode the request body. The '
53
                'Could not decode the request body. The '
53
                'JSON was incorrect.')
54
                'JSON was incorrect.')
54
        try:
55
        try:
55
            store = main.getStore(req.get_param_as_int("storeId"))
56
            store = main.getStore(req.get_param_as_int("storeId"))
56
            if req.get_param_as_int("storeId") == 1:
57
            if req.get_param_as_int("storeId") == 1:
57
                result = store.trackOrdersForUser(int(userId),1,2)
58
                result = store.trackOrdersForUser(int(userId),req_obj['url'],req_obj['html'])
58
                resp.body = json.dumps({'result':result}, encoding='utf-8')
59
                resp.body = json.dumps({'result':result}, encoding='utf-8')
59
            else:
60
            else:
60
                resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
61
                resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
61
        except:
62
        except:
62
            resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')
63
            resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')