Subversion Repositories SmartDukaan

Rev

Rev 13573 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

import os
import sys
import falcon

sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/falcon-0.2.0b2-py2.6.egg/')
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/six-1.9.0-py2.6.egg/')
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/python_mimeparse-0.1.4-py2.6.egg/')
sys.path.insert(0, '/home/anupam/code/trunk/PyProj/src')
print(sys.path)
import json
from dtr.storage import Mongo 


class CategoryDiscountInfo(object):
    
    def on_get(self, req, resp):
        
        resp.body = str(Mongo.getAllCategoryDiscount()) 
    
    def on_post(self, req, resp):
        
        try:
            result_json = json.loads(req.stream.read(), encoding='utf-8')
        except ValueError:
            raise falcon.HTTPError(falcon.HTTP_400,
                'Malformed JSON',
                'Could not decode the request body. The '
                'JSON was incorrect.')
            
        result = Mongo.addCategoryDiscount(result_json)
        resp.body = json.dumps(result, encoding='utf-8')

class SkuSchemeDetails(object):
    
    def on_get(self, req, resp):

        resp.body = str(Mongo.getAllSkuWiseSchemeDetails()) 
    
    def on_post(self, req, resp):
        
        try:
            result_json = json.loads(req.stream.read(), encoding='utf-8')
        except ValueError:
            raise falcon.HTTPError(falcon.HTTP_400,
                'Malformed JSON',
                'Could not decode the request body. The '
                'JSON was incorrect.')
            
        result = Mongo.addSchemeDetailsForSku(result_json)
        resp.body = json.dumps(result, encoding='utf-8')
        
class SkuDiscountInfo():
    
    def on_get(self, req, resp):

        resp.body = str(Mongo.getallSkuDiscountInfo()) 
    
    def on_post(self, req, resp):
        
        try:
            result_json = json.loads(req.stream.read(), encoding='utf-8')
        except ValueError:
            raise falcon.HTTPError(falcon.HTTP_400,
                'Malformed JSON',
                'Could not decode the request body. The '
                'JSON was incorrect.')
            
        result = Mongo.addSkuDiscountInfo(result_json)
        resp.body = json.dumps(result, encoding='utf-8')

class ExceptionalNlc():
    
    def on_get(self, req, resp):

        resp.body = str(Mongo.getAllExceptionlNlcItems()) 
    
    def on_post(self, req, resp):
        
        try:
            result_json = json.loads(req.stream.read(), encoding='utf-8')
        except ValueError:
            raise falcon.HTTPError(falcon.HTTP_400,
                'Malformed JSON',
                'Could not decode the request body. The '
                'JSON was incorrect.')
            
        result = Mongo.addExceptionalNlc(result_json)
        resp.body = json.dumps(result, encoding='utf-8')