Esempio n. 1
0
#                print('Validation of ' + object_id + ' failed.')
#                print(e)
#
#            # did validate
#            else:
#                # inform the user of the success
#                print('Validation of ' + object_id + ' succeeded.')
#
#                # post the new object(s).  SHOULD HANDLE ERRORS GRACEFULLY
#                response = new_ENCODE(object_collection,new_object)

        # if object is not found, verify and post it
        if (old_object.get(u'title') == u'Not Found') | (old_object.get(u'title') == u'Home'):

            # clean object of unpatchable or nonexistent properties.  SHOULD INFORM USER OF ANYTHING THAT DOESN"T GET POSTED.
            new_object = CleanJSON(new_object,object_schema,'POST')
    
            new_object = FlatJSON(new_object,keys)
            print(new_object)

            # test the new object       
            if ValidJSON(object_type,object_id,new_object,keys):
                # post the new object(s).  SHOULD HANDLE ERRORS GRACEFULLY
                new_object = CleanJSON(new_object,object_schema,'POST')
                response = new_ENCODE(object_type,new_object,keys)
                
                object_check = GetENCODE(str(response[u'@graph'][0][u'@id']),keys)
                print(object_check[u'@id'], object_check[u'uuid'])

        # if object is found, check for differences and patch it if needed/valid.
        elif put_status: