Subversion Repositories SmartDukaan

Rev

Rev 13573 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13572 kshitij.so 1
import os
2
import sys
3
import falcon
4
 
5
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/falcon-0.2.0b2-py2.6.egg/')
6
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/six-1.9.0-py2.6.egg/')
7
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/python_mimeparse-0.1.4-py2.6.egg/')
8
sys.path.insert(0, '/home/anupam/code/trunk/PyProj/src')
9
print(sys.path)
10
import json
11
from dtr.storage import Mongo 
12
 
13
 
14
class CategoryDiscountInfo(object):
15
 
16
    def on_get(self, req, resp):
17
 
18
        resp.body = str(Mongo.getAllCategoryDiscount()) 
19
 
20
    def on_post(self, req, resp):
21
 
22
        try:
23
            result_json = json.loads(req.stream.read(), encoding='utf-8')
24
        except ValueError:
25
            raise falcon.HTTPError(falcon.HTTP_400,
26
                'Malformed JSON',
27
                'Could not decode the request body. The '
28
                'JSON was incorrect.')
29
 
30
        result = Mongo.addCategoryDiscount(result_json)
31
        resp.body = json.dumps(result, encoding='utf-8')
32
 
33
class SkuSchemeDetails(object):
34
 
35
    def on_get(self, req, resp):
36
 
37
        resp.body = str(Mongo.getAllSkuWiseSchemeDetails()) 
38
 
39
    def on_post(self, req, resp):
40
 
41
        try:
42
            result_json = json.loads(req.stream.read(), encoding='utf-8')
43
        except ValueError:
44
            raise falcon.HTTPError(falcon.HTTP_400,
45
                'Malformed JSON',
46
                'Could not decode the request body. The '
47
                'JSON was incorrect.')
48
 
49
        result = Mongo.addSchemeDetailsForSku(result_json)
50
        resp.body = json.dumps(result, encoding='utf-8')
51
 
52
class SkuDiscountInfo():
53
 
54
    def on_get(self, req, resp):
55
 
56
        resp.body = str(Mongo.getallSkuDiscountInfo()) 
57
 
58
    def on_post(self, req, resp):
59
 
60
        try:
61
            result_json = json.loads(req.stream.read(), encoding='utf-8')
62
        except ValueError:
63
            raise falcon.HTTPError(falcon.HTTP_400,
64
                'Malformed JSON',
65
                'Could not decode the request body. The '
66
                'JSON was incorrect.')
67
 
68
        result = Mongo.addSkuDiscountInfo(result_json)
69
        resp.body = json.dumps(result, encoding='utf-8')
70
 
71
class ExceptionalNlc():
72
 
73
    def on_get(self, req, resp):
74
 
75
        resp.body = str(Mongo.getAllExceptionlNlcItems()) 
76
 
77
    def on_post(self, req, resp):
78
 
79
        try:
80
            result_json = json.loads(req.stream.read(), encoding='utf-8')
81
        except ValueError:
82
            raise falcon.HTTPError(falcon.HTTP_400,
83
                'Malformed JSON',
84
                'Could not decode the request body. The '
85
                'JSON was incorrect.')
86
 
87
        result = Mongo.addExceptionalNlc(result_json)
88
        resp.body = json.dumps(result, encoding='utf-8')
89