• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.DBSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: edit_role2

def edit_role2(post, permissions):
    #Обновлеяем запись
    obj = get_role2(post['id'])
    if not obj:
        return False
    obj.name = post['rolename']
    obj.rolesgroup = post['rolegroup']
    obj.description = post['description']
    obj.ordering = post['order']  
    
    #Удаляем роли
    DBSession.query(PermissionsRoles).filter(PermissionsRoles.role_id == post['id']).delete()
            
    #Добавляем роли
    for e in permissions:
        pr = PermissionsRoles(post['id'], e)
        DBSession.add(pr)  
    
    try:
        transaction.commit()
    except:
        transaction.rollback()
        return False
    else:
        return True
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:25,代码来源:roles_func.py


示例2: get_posts

def get_posts(offset=None, limit=None):
    
    setallroute()
    
    if offset==None or limit==None:
        return DBSession.query(Blogs).all()
    else:
        return (DBSession.query(Blogs).all())[offset:limit]
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:8,代码来源:posts_func.py


示例3: get_roles

def get_roles(offset=None, limit=None):
    
    #Добавить короткое описание
    setopt(Roles, 'shortdesc', Roles_shortdesc)
    
    if offset==None or limit==None:
        return DBSession.query(Roles).all()
    else:
        return DBSession.query(Roles).all()[offset:limit]
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:9,代码来源:roles_func.py


示例4: get_users

def get_users(offset=None, limit=None):

    # Форматирование даты и активности
    setallroute()

    if offset == None or limit == None:
        return DBSession.query(Users).all()
    else:
        return (DBSession.query(Users).all())[offset:limit]
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:9,代码来源:users_func.py


示例5: get_permissions2

def get_permissions2(offset=None, limit=None):
    
    #Добавить короткое описание
    setopt(Permissions, 'shortdesc', Permissions_shortdesc)
    
    if offset==None or limit==None:
        return DBSession.query(Permissions).all()
    else:
        return DBSession.query(Permissions).all()[offset:limit]
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:9,代码来源:permissions_func.py


示例6: delete_permissions

def delete_permissions(delitems):
    try:
        for e in delitems:
            DBSession.query(Permissions).filter(Permissions.id == e).delete()
        transaction.commit()
        result = 1
    except:
        transaction.rollback()
        result = 0
    return result
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:10,代码来源:permissions_func.py


示例7: new_accesslog

def new_accesslog(ip, e=1, u=0):
    
    l = AccessLog(ip, e, user_id=u)
    DBSession.add(l)
    
    try:
        transaction.commit()
    except:
        DBSession.rollback()
        return False
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:10,代码来源:auth_func.py


示例8: delete_posts

def delete_posts(delitems, thread='blog'):
    try:
        for e in delitems:
            DBSession.query(Blogs).filter(Blogs.id == e).delete()
            DBSession.query(Comments).filter(Comments.thread == thread).filter(Comments.threadid == e).delete()
        transaction.commit()
        result = 1
    except:
        transaction.rollback()
        result = 0
    return result
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:11,代码来源:posts_func.py


示例9: put_userprofile

def put_userprofile(userid, post):
    p = DBSession.query(Profiles).filter(Profiles.userid == userid).one()
    
    p.fullname = post['fullname']
    
    try:
        transaction.commit()
    except:
        DBSession.rollback()
        return False
    else:
        return True
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:12,代码来源:profile_func.py


示例10: delete_comment

def delete_comment(itemid):

    DBSession.query(Comments).filter(Comments.id == itemid).delete()

    try:
        transaction.commit()
        result = 1
    except:
        DBSession.rollback()
        result = 0

    return result
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:12,代码来源:comments_func.py


示例11: db_set_avatar

def db_set_avatar(post):
    p = DBSession.query(Profiles).filter(Profiles.userid == post['id']).all()
    if not p[0]:
        return False
    p[0].avatar1 = post['avatarsource']
    p[0].avatar2 = post['avatarsize1']
    p[0].avatar3 = post['avatarsize2']
    
    try:
        transaction.commit()
    except:
        DBSession.rollback()
        return False
    else:
        return True
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:15,代码来源:profile_func.py


示例12: set_userpassword

def set_userpassword(post):
    setopt(Users, 'check_password', Users_check_password)
    user = DBSession.query(Users).filter(Users.id == post['userid']).one()
    if user.check_password(post['oldpassword']):
        user.password = hash_password(post['password'])
        
        try:
            transaction.commit()
        except:
            DBSession.rollback()
            return False
        else:
            return 1
        
    else:
        return 2
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:16,代码来源:profile_func.py


示例13: get_user

def get_user(username):
    setopt(Users, 'check_password', Users_check_password)
    user = DBSession.query(Users).filter(Users.username == username).all()
    if user:
        return user[0]
    else:
        return None
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:7,代码来源:auth_func.py


示例14: get_accesslog_badlogin

def get_accesslog_badlogin(ip, e=1, t=180, attempt=3):
    
    ls = DBSession.query(AccessLog).filter(AccessLog.event_id == e).filter(AccessLog.ip == ip).filter(AccessLog.eventdate > int(time.time())-180).count()
    if ls < attempt:
        return True
    else:
        return False
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:7,代码来源:auth_func.py


示例15: db_count_comments

def db_count_comments(thread, threadid):
    return (
        DBSession.query(Comments)
        .filter(Comments.thread == thread)
        .filter(Comments.published == 1)
        .filter(Comments.threadid == threadid)
        .count()
    )
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:8,代码来源:comments_func.py


示例16: edit_comment

def edit_comment(itemid, title, content):

    ts = int(time.time())

    obj = get_comment(itemid)
    obj.title = title
    obj.content = content
    obj.last_edited = ts

    try:
        transaction.commit()
        result = 1
    except:
        DBSession.rollback()
        result = 0

    return result
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:17,代码来源:comments_func.py


示例17: count_comments

def count_comments(component, componentid):
    return (
        DBSession.query(Comments)
        .filter(Comments.thread == component)
        .filter(Comments.threadid == componentid)
        .filter(Comments.published == 1)
        .count()
    )
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:8,代码来源:comments_func.py


示例18: get_comment2

def get_comment2(id, ordering="id", component="blog", componentid=1):
    # Вывод с форматированием даты
    setopt(Comments, "datefromtimestamp", Comments_datefromtimestamp)
    return (
        DBSession.query(Comments)
        .filter(Comments.id == id)
        .filter(Comments.thread == component)
        .filter(Comments.threadid == componentid)
        .one()
    )
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:10,代码来源:comments_func.py


示例19: get_posts2

def get_posts2(post, orderbytable, offset, limit):
    
    for key in orderbytable.keys():
        if post['col'] == key:
            order_by=orderbytable[key]
    
    if post['asc'] == '1':
        ordering = asc(order_by)
    if post['asc'] == '0':
        ordering = desc(order_by)
    
    if 'phr' in post:
        if post['phr'] != '':
            phr = '%'+ post['phr'] +'%'
            filter = (dict(Blogs.__dict__))[post['lke']].like(phr)
            blogs = (DBSession.query(Blogs).filter(filter).order_by(ordering).all())[offset:limit]
    else:
        blogs = (DBSession.query(Blogs).order_by(ordering).all())[offset:limit]
    return blogs
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:19,代码来源:posts_func.py


示例20: db_put_comment

def db_put_comment(itemid, post):

    p = get_bbparser()

    content = p.format(post["content"])

    obj = get_comment(itemid)
    obj.title = post["title"]
    obj.content = content
    obj.last_edited = post["last_edited"]

    try:
        transaction.commit()
        result = 1
    except:
        DBSession.rollback()
        result = 0

    return (result, content)
开发者ID:lightarhont,项目名称:startwithpyramid,代码行数:19,代码来源:comments_func.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.UI类代码示例发布时间:2022-05-27
下一篇:
Python testoob.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap