當前位置: 首頁>>代碼示例>>Python>>正文


Python meta.Session類代碼示例

本文整理匯總了Python中argonaut.model.meta.Session的典型用法代碼示例。如果您正苦於以下問題:Python Session類的具體用法?Python Session怎麽用?Python Session使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Session類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

def get(id, active_only=True):
    try:
        if active_only:
            return Session.query(Post).filter(Post.status == 1).filter(Post.id == id).first()
        else:
            return Session.query(Post).get(id)
    except TypeError:
        return None
開發者ID:jaywink,項目名稱:argonaut,代碼行數:8,代碼來源:post.py

示例2: add_to_post

def add_to_post(tag_id,post_id):
    try:
        tag_post = Tag_Post(None,post_id,tag_id)
        Session.add(tag_post)
        Session.commit()
    except:
        # Couldn't add tag to post - already exists!
        # TODO: This should be logged to avoid future nasty bugs
        pass
開發者ID:jaywink,項目名稱:argonaut,代碼行數:9,代碼來源:tag_post.py

示例3: __call__

 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:9,代碼來源:base.py

示例4: init_data

def init_data():
    print "Initing box data"
    query = Session.query(Box)
    for rec in values:
        if not query.get(rec[0]):
            item = Box()
            item.name = unicode(rec[1])
            item.template = unicode(rec[2])
            Session.add(item)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:10,代碼來源:box_data.py

示例5: init_data

def init_data():
    print "Initing config data"
    query = Session.query(Config)
    for rec in values:
        if not query.get(unicode(rec[0])):
            config = Config()
            config.id = unicode(rec[0])
            config.value = unicode(rec[1])
            Session.add(config)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:10,代碼來源:config_data.py

示例6: init_data

def init_data():
    print "Initing boxes data"
    query = Session.query(Boxes)
    for rec in values:
        if not query.get(rec[0]):
            item = Boxes()
            item.box_id = rec[1]
            item.status = rec[2]
            item.order = rec[3]
            Session.add(item)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:11,代碼來源:boxes_data.py

示例7: init_data

def init_data():
    print "Initing media data"
    query = Session.query(Media)
    for rec in values:
        if not query.get(rec[0]):
            media = Media()
            media.id = rec[0]
            media.name = unicode(rec[1])
            media.url = unicode(rec[2])
            Session.add(media)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:11,代碼來源:media_data.py

示例8: init_data

def init_data():
    print "Initing page_type data"
    query = Session.query(Page_Type)
    for rec in values:
        if not query.get(rec[0]):
            page_type = Page_Type()
            page_type.id = rec[0]
            page_type.name = unicode(rec[1])
            page_type.controller = unicode(rec[2])
            page_type.action = unicode(rec[3])
            page_type.param = unicode(rec[4])
            Session.add(page_type)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:13,代碼來源:page_type_data.py

示例9: init_data

def init_data():
    print "Initing page data"
    query = Session.query(Page)
    for rec in values:
        if not query.get(rec[0]):
            page = Page()
            page.id = rec[0]
            page.name = unicode(rec[1])
            page.status = rec[2]
            page.page_order = rec[3]
            page.url = unicode(rec[4])
            page.type = rec[5]
            Session.add(page)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:14,代碼來源:page_data.py

示例10: init_data

def init_data():
    print "Initing social data"
    query = Session.query(Social)
    for rec in values:
        if not query.get(rec[0]):
            social = Social()
            social.id = rec[0]
            social.name = unicode(rec[1])
            social.status = rec[2]
            social.priority = rec[3]
            social.url = unicode(rec[4])
            social.media_id = rec[5]
            Session.add(social)
            Session.commit()
開發者ID:jaywink,項目名稱:argonaut,代碼行數:14,代碼來源:social_data.py

示例11: get_tag_counts

def get_tag_counts(order=False):
    from argonaut.model.tag import Tag
    if order:
        s = select([Tag.name, func.count(Tag_Post.tag_id)], Tag.id == Tag_Post.tag_id).group_by(Tag.name).order_by(func.count(Tag_Post.tag_id).desc())
    else:
        s = select([Tag.name, func.count(Tag_Post.tag_id)], Tag.id == Tag_Post.tag_id).group_by(Tag.name)
    tags = Session.execute(s)
    return tags
開發者ID:jaywink,項目名稱:argonaut,代碼行數:8,代碼來源:tag_post.py

示例12: get_url

def get_url(id, url_param):
    route = Session.query(Page_Type).get(id)
    if url_param:
        target = url(controller=route.controller, action=route.action, id=url_param)
    elif len(route.param) > 0:
        target = url(controller=route.controller, action=route.action, id=route.param)
    else:
        target = url(controller=route.controller, action=route.action)
    return target
開發者ID:jaywink,項目名稱:argonaut,代碼行數:9,代碼來源:page_type.py

示例13: get_many

def get_many(amount=10, order='asc', active_only=True, count_only=False, filter=None):
    try:
        query = Session.query(Post)
        if active_only:
            query = query.filter(Post.status == 1)
        if filter:
            query = query.filter(or_(Post.subject.like('%'+filter+'%'),Post.body.like('%'+filter+'%')))
        if count_only:
            return query.limit(amount).count()
        else:
            if order == 'desc':
                return query.order_by(Post.id.desc()).limit(amount)
            else:
                return query.order_by(Post.id.asc()).limit(amount)
    except Exception:
        return None
開發者ID:jaywink,項目名稱:argonaut,代碼行數:16,代碼來源:post.py

示例14: get_tags

def get_tags(id):
    from argonaut.model.post import Post
    from argonaut.model.tag import Tag
    return Session.query(Tag).filter(Post.id==id).filter(Post.id==Tag_Post.post_id).filter(Tag_Post.tag_id==Tag.id).all()   
開發者ID:jaywink,項目名稱:argonaut,代碼行數:4,代碼來源:tag_post.py

示例15: get_page_id_with_type

def get_page_id_with_type(type):
    from argonaut.model.page_type import Page_Type
    return int(Session.query(Page).join(Page_Type).filter(Page_Type.name==type).order_by(Page.id.desc()).first().id)
開發者ID:jaywink,項目名稱:argonaut,代碼行數:3,代碼來源:page.py


注:本文中的argonaut.model.meta.Session類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。