Subversion Repositories SmartDukaan

Rev

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

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