当前位置: 首页>>代码示例>>Python>>正文


Python db.DBApiModule类代码示例

本文整理汇总了Python中app.db.DBApiModule的典型用法代码示例。如果您正苦于以下问题:Python DBApiModule类的具体用法?Python DBApiModule怎么用?Python DBApiModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DBApiModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getUserByName

def getUserByName(name):
    conn = db.connect()
    rows = db.selectFrom(conn, {"user"}, "*", name = name)
    if rows == []:
        #raise Exception("user not found")
        return None
    return User(rows)
开发者ID:lutzer,项目名称:sahabe,代码行数:7,代码来源:User.py

示例2: testDropPWByUser

 def testDropPWByUser(self):
     self.insertUser(self.id, self.name, self.email)
     self.insertPW(self.pw.userId, self.pw.value, self.pw.salt)
     
     db.deleteFromTable(self.conn, "user", id=self.id) 
     row = db.selectFrom(self.conn, {"pw_hash"}, "*", user_id=self.id)
     self.assertEqual(row, [])
开发者ID:lutzer,项目名称:sahabe,代码行数:7,代码来源:User.py

示例3: addLink

def addLink(form, userId):
    linkId = utils.uuid()
    kwargs = {}
    kwargs["id"] = linkId
    
    kwargs["user_id"] = userId
    
    if form.has_key("url") :
        kwargs["url"]=form["url"]
        kwargs["url_hash"] = hashlib.md5(kwargs["url"]).hexdigest() 
    else:
        raise Exception("an url must be added")

    if form.has_key("title"): 
        kwargs["title"]=form["title"] 
    
    if form.has_key("description"):
        kwargs["description"]=form["description"]
        
    if form.has_key("typeName"):
        kwargs["type_name"]=form["typeName"]
    
    kwargs["modified_at"]=utils.timeStamp()
    
    #FIXME use other algorithms to get icon logo
    iconUrl = utils.extractHomeUrl(kwargs["url"])+"favicon.ico"

    conn = db.connect()
    db.insertToTable(conn,
                     "link",
                    **kwargs)
    MetaData.addIconUrl(linkId, iconUrl)
    
    return kwargs
开发者ID:lutzer,项目名称:sahabe,代码行数:34,代码来源:LinkStorage.py

示例4: testDropMetaDataByLink

 def testDropMetaDataByLink(self):
     self.insertLink(self.id, self.userId, self.url, self.urlHash, self.title,
                     self.desc, self.typeName , self.modifiedAt)
     self.insertMetaData(self.metaData.linkId, self.metaData.key, self.metaData.value)
     
     db.deleteFromTable(self.conn, "link", id=self.id)
     row = db.selectFrom(self.conn, {"meta_data"}, "*", link_id=self.metaData.linkId)
     self.assertEqual(row, []) 
开发者ID:lutzer,项目名称:sahabe,代码行数:8,代码来源:Link.py

示例5: testDropGroupByUser

 def testDropGroupByUser(self):
     self.insertUser(self.id, self.name, self.email)
     self.insertGroup(self.group.id, self.group.name, self.group.public)
     
     db.deleteFromTable(self.conn, "user", id=self.id)
     row = db.selectFrom(self.conn, {"link_group"}, "*" , id=self.group.id)
     # FIXME: when a user is deleted all of his groups must be removed
     self.assertEqual(row, [])
开发者ID:lutzer,项目名称:sahabe,代码行数:8,代码来源:User.py

示例6: testDropTagByUser

 def testDropTagByUser(self):
     self.insertUser(self.id, self.name, self.email)
     self.insertTag(self.tag.id, self.tag.name)
     
     db.deleteFromTable(self.conn, "user", id=self.id)
     row = db.selectFrom(self.conn, {"tag"}, "*" , id=self.tag.id)
     # FIXME: when a user is deleted all of his tags must be removed 
     self.assertEqual(row, [])
开发者ID:lutzer,项目名称:sahabe,代码行数:8,代码来源:User.py

示例7: createUser

def createUser(userForm):
    conn = db.connect()
    userId = str(uuid.uuid4())
    db.insertToTable(conn, "user",
                     id=userId,
                     name=userForm["username"],
                     email=userForm["email"])
    return userId
开发者ID:lutzer,项目名称:sahabe,代码行数:8,代码来源:User.py

示例8: testDropLinkTagMapByLink

 def testDropLinkTagMapByLink(self):
     self.insertLink(self.id, self.userId, self.url, self.urlHash, self.title,
                     self.desc, self.typeName , self.modifiedAt)
     self.insertTag(self.tag.id, self.tag.name)
     self.insertLinkTagMap(self.linkTagMap.tagId, self.linkTagMap.linkId)
     
     db.deleteFromTable(self.conn, "link", id=self.id)
     row = db.selectFrom(self.conn, {"link_tag_map"}, "*", link_id=self.linkTagMap.linkId)
     self.assertEqual(row, [])
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Link.py

示例9: testUpdateName

 def testUpdateName(self):
     self.insertTag(self.id, self.name)
     name = mock.randomText()
     db.updateInTable(self.conn, {"name":name}, "tag", id=self.id)
     
     rows = db.selectFrom(self.conn, {"tag"}, "*", id=self.id)
     
     self.assertEqual(self.id, rows[0][0])
     self.assertEqual(name, rows[0][1])
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Tag.py

示例10: testUpdateId

 def testUpdateId(self):
     self.insertTag(self.id, self.name)
     _id = mock.uuid()
     db.updateInTable(self.conn, {"id":_id}, "tag", id=self.id)
     
     rows = db.selectFrom(self.conn, {"tag"}, "*", id=_id)
     
     self.assertEqual(_id, rows[0][0])
     self.assertEqual(self.name, rows[0][1])
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Tag.py

示例11: testUpdatePublic

 def testUpdatePublic(self):
     self.insertGroup(self.id, self.name, self.public)
     db.updateInTable(self.conn, {"public":"1"}, "link_group", id=self.id)
     
     rows = db.selectFrom(self.conn, {"link_group"}, "*", id=self.id)
     
     self.assertEqual(self.id, rows[0][0])
     self.assertEqual(self.name, rows[0][1])
     self.assertEqual(1, rows[0][2])
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Group.py

示例12: createPasswordForUser

def createPasswordForUser(userId, password):
    conn = db.connect()
    value = hashlib.sha256(password).hexdigest()
    salt = hashlib.sha256(value+userId).hexdigest()
    db.insertToTable(conn, "pw_hash",
                     user_id=userId,
                     value=value,
                     salt=salt)
    return True
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Password.py

示例13: testDropLinkGroupMapByLink

 def testDropLinkGroupMapByLink(self):
     self.insertLink(self.id, self.userId, self.url, self.urlHash, self.title,
                     self.desc, self.typeName , self.modifiedAt)
     self.insertGroup(self.group.id, self.group.name, self.group.public)
     self.insertLinkGroupMap(self.linkGroupMap.groupId, self.linkGroupMap.linkId)
     
     db.deleteFromTable(self.conn, "link", id=self.id)
     row = db.selectFrom(self.conn, {"link_group_map"}, "*", link_id=self.linkGroupMap.linkId)
     self.assertEqual(row, [])
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Link.py

示例14: testInsertNoTypeName

 def testInsertNoTypeName(self):
     db.insertToTable(self.conn, "link",
                       id=self.id,
                       user_id=self.userId,
                       url=self.url,
                       url_hash=self.urlHash,
                       title=self.title,
                       description=self.desc,
                       modified_at=self.modifiedAt)
开发者ID:lutzer,项目名称:sahabe,代码行数:9,代码来源:Link.py

示例15: testEmail

 def testEmail(self):
     self.insertUser(self.id, self.name, self.email)
     email = mock.randomText()
     db.updateInTable(self.conn, {"email":email}, "user", id=self.id)
     
     rows = db.selectFrom(self.conn, {"user"}, "*", id=self.id)
     
     self.assertEqual(self.id, rows[0][0])
     self.assertEqual(self.name, rows[0][1])
     self.assertEqual(email, rows[0][2])
开发者ID:lutzer,项目名称:sahabe,代码行数:10,代码来源:User.py


注:本文中的app.db.DBApiModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。