# -*- coding: utf-8 -*-
'''
Created on 16 janv. 2016

@author: romain
'''

import falcon

from db import db

class Address(object):
    '''
    Patch maps information related to an address
    '''

    def patch_json_is_valid(self, patch_json):
        
        is_valid = True
        if patch_json is None:
            is_valid = False
        return is_valid

    def on_patch(self, req, resp):
        '''Update database according to JSON and give ID back
        '''
        
        
        patch_json = req.stream.read()
        print(patch_json)
        if not self.patch_json_is_valid(patch_json):
            resp.status = falcon.HTTP_400
        else:
            return
@@ -81,16 +81,28 @@
 t falcon
+%0Aimport json
 %0A%0Afrom d
@@ -368,16 +368,366 @@
 _valid%0A%0A
+    def get_json_list(self, patch_json):%0A        %0A        if not self.patch_json_is_valid(patch_json):%0A            raise ValueError(%22None found, expected a JSON string%22)%0A        %0A        patch = json.loads(patch_json)%0A        %0A        if not isinstance(patch, dict):%0A            raise ValueError(%22Json does not contain a dict%22)%0A        return patch%0A%0A
     def 
@@ -836,25 +836,16 @@
        %0A
-        %0A
         
@@ -878,74 +878,85 @@
 ad()
-%0A        print(patch_json)%0A        if not
+.decode('utf-8')%0A        %0A        try:%0A            patch =
  self.
-patch
+get
 _json_
-is_valid
+list
 (pat
@@ -955,32 +955,47 @@
 list(patch_json)
+%0A        except
 :%0A            re
@@ -1036,16 +1036,41 @@
   else:%0A
+            print(patch)%0A
         

Manage Json