Subversion Repositories SmartDukaan

Rev

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

Rev 14589 Rev 14592
Line 172... Line 172...
172
        update = req.get_param_as_int("update")
172
        update = req.get_param_as_int("update")
173
        addToExisting = req.get_param_as_int("addToExisting")
173
        addToExisting = req.get_param_as_int("addToExisting")
174
        multi = req.get_param_as_int("multi")
174
        multi = req.get_param_as_int("multi")
175
        
175
        
176
        try:
176
        try:
177
 
-
 
178
            try:
-
 
179
                result_json = json.loads(req.stream.read(), encoding='utf-8')
177
            result_json = json.loads(req.stream.read(), encoding='utf-8')
180
            except ValueError:
178
        except ValueError:
181
                raise falcon.HTTPError(falcon.HTTP_400,
179
            raise falcon.HTTPError(falcon.HTTP_400,
182
                    'Malformed JSON',
180
                'Malformed JSON',
183
                    'Could not decode the request body. The '
181
                'Could not decode the request body. The '
184
                    'JSON was incorrect.')
182
                'JSON was incorrect.')
185
                
183
            
186
            if addNew == 1:
184
        if addNew == 1:
187
                result = Mongo.addNewItem(result_json)
185
            result = Mongo.addNewItem(result_json)
188
            elif update == 1:
186
        elif update == 1:
189
                result = Mongo.updateMaster(result_json, multi)
187
            result = Mongo.updateMaster(result_json, multi)
190
            elif addToExisting == 1:
188
        elif addToExisting == 1:
191
                result = Mongo.addItemToExistingBundle(result_json)
189
            result = Mongo.addItemToExistingBundle(result_json)
192
            else:
190
        else:
193
                raise
191
            raise
194
            resp.body = dumps(result)
192
        resp.body = dumps(result)
195
        except:
-
 
196
            resp.body = dumps({'0':'Illegal operation.'})
-
 
197
    
193
    
198
class LiveData():
194
class LiveData():
199
    def on_get(self,req, resp):
195
    def on_get(self,req, resp):
200
        if req.get_param_as_int("id") is not None:
196
        if req.get_param_as_int("id") is not None:
201
            print "****getting only for id"
197
            print "****getting only for id"