示例#1
0
文件: api.py 项目: mshron/Bluebird
def put(attrs, obj_type=None):
    '''write an object in dictionary representation to datastore'''
    if obj_type:
        attrs['type'] = obj_type
    obj = data.parse_obj(attrs)
    # ensure current user is author of new revision
    if hasattr(obj, 'author'):
        obj.author = fl.g.user.key
    key = ds.put(obj)
    return key.id() if key else ''
示例#2
0
 def get_all(self, col):
     url = '/api/%s' % col
     print 'GET from: %s' % url
     resp = self.app.get(path=url)
     self.assertEqual(resp.status_code, 200,
                      'GET request on URL=%s returned status: %s' 
                      % (url, resp.status))
     attrs_list = json.loads(resp.data)
     obj_list = [data.parse_obj(a) for a in attrs_list]
     return obj_list