def info(self, _id, key='_id'): ''' show info by _id ''' not_empty(_id) if key == '_id': _id = ObjectId(_id) cond = {key:_id} return mongo_conv(self._coll().find_one(cond))
def get(fid): """ 获取文件内容和元数据 参数: fid 文件唯一编号 返回: (data, meta) 文件内容(字节数组), 元属性字典 """ if type(fid) is not ObjectId: fid = ObjectId(fid) gfs = get_context().get_gfs() with gfs.get(fid) as out: data, meta = out.read(), mongo_conv(out._file) if meta.get("gzip"): data = decompress(data) return data, meta
def login(self, user): user = mongo_conv(user) self.set_secure_cookie(AUTH_KEY, json.dumps(user))