Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
Arquivo: gfs.py Projeto: zhangxj/web
    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
Exemplo n.º 3
0
Arquivo: web.py Projeto: comger/kpages
 def login(self, user):
     user = mongo_conv(user)
     self.set_secure_cookie(AUTH_KEY, json.dumps(user))
Exemplo n.º 4
0
 def login(self, user):
     user = mongo_conv(user)
     self.set_secure_cookie(AUTH_KEY, json.dumps(user))