Subversion Repositories SmartDukaan

Rev

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

Rev 14010 Rev 14011
Line 42... Line 42...
42
        resp.body = json.dumps(result, encoding='utf-8')
42
        resp.body = json.dumps(result, encoding='utf-8')
43
        
43
        
44
class Track():
44
class Track():
45
    def on_post(self, req, resp, userId):
45
    def on_post(self, req, resp, userId):
46
        try:
46
        try:
47
            string1 = req.stream.read()
-
 
48
            req_json = json.loads(string1, encoding='utf-8')
-
 
49
            print req_json
-
 
50
        except ValueError:
-
 
51
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
52
                'Malformed JSON',
-
 
53
                'Could not decode the request body. The '
-
 
54
                'JSON was incorrect.')
-
 
55
        try:
-
 
56
            store = main.getStore(req.get_param_as_int("storeId"))
47
            store = main.getStore(req.get_param_as_int("storeId"))
57
            if req.get_param_as_int("storeId") == 1:
48
            if req.get_param_as_int("storeId") == 1:
58
                result = store.trackOrdersForUser(int(userId),req_json['url'],req_json['html'])
49
                result = store.trackOrdersForUser(int(userId),req.get_param('url'),req.get_param('html'))
59
                resp.body = json.dumps({'result':result}, encoding='utf-8')
50
                resp.body = json.dumps({'result':result}, encoding='utf-8')
60
            else:
51
            else:
61
                resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
52
                resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
62
        except:
53
        except:
63
            resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')
54
            resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')