Subversion Repositories SmartDukaan

Rev

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

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