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


Python Session.query方法代码示例

本文整理汇总了Python中mediagoblin.db.base.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Python Session.query方法的具体用法?Python Session.query怎么用?Python Session.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mediagoblin.db.base.Session的用法示例。


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

示例1: check_media_slug_used

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
def check_media_slug_used(dummy_db, uploader_id, slug, ignore_m_id):
    filt = (MediaEntry.uploader == uploader_id) \
        & (MediaEntry.slug == slug)
    if ignore_m_id is not None:
        filt = filt & (MediaEntry.id != ignore_m_id)
    does_exist = Session.query(MediaEntry.id).filter(filt).first() is not None
    return does_exist
开发者ID:orblivion,项目名称:mediagoblin-quickstart-openshift,代码行数:9,代码来源:util.py

示例2: check_collection_slug_used

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
def check_collection_slug_used(creator_id, slug, ignore_c_id):
    filt = (Collection.creator == creator_id) \
        & (Collection.slug == slug)
    if ignore_c_id is not None:
        filt = filt & (Collection.id != ignore_c_id)
    does_exist = Session.query(Collection.id).filter(filt).first() is not None
    return does_exist
开发者ID:praveen97uma,项目名称:goblin,代码行数:9,代码来源:util.py

示例3: clean_orphan_tags

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
def clean_orphan_tags(commit=True):
    """Search for unused MediaTags and delete them"""
    q1 = Session.query(Tag).outerjoin(MediaTag).filter(MediaTag.id==None)
    for t in q1:
        Session.delete(t)
    # The "let the db do all the work" version:
    # q1 = Session.query(Tag.id).outerjoin(MediaTag).filter(MediaTag.id==None)
    # q2 = Session.query(Tag).filter(Tag.id.in_(q1))
    # q2.delete(synchronize_session = False)
    if commit:
        Session.commit()
开发者ID:praveen97uma,项目名称:goblin,代码行数:13,代码来源:util.py

示例4: get_all_blogposts_of_blog

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
def get_all_blogposts_of_blog(request, blog, state=None):
    """Return all blog posts (and metadata) of a blog as query object"""
    # TODO: I would simply make this function a method of the Blog() class.

    # next line is just providing shortcuts
    MediaEntry, BlogPostData = request.db.MediaEntry, request.db.BlogPostData
    blog_posts = Session.query(MediaEntry).join(BlogPostData)\
	.filter(BlogPostData.blog == blog.id)
    if state is not None:
 	blog_posts = blog_posts.filter(MediaEntry.state==state)
    # we could return the metadata (blog_posts_meta) here too and save some queries later
    return blog_posts
开发者ID:spaetz,项目名称:mediagoblin_blog,代码行数:14,代码来源:lib.py

示例5: media_data_init

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
    def media_data_init(self, **kwargs):
        """
        Initialize or update the contents of a media entry's media_data row
        """
        session = Session()

        media_data = session.query(self.media_data_table).filter_by(
            media_entry=self.id).first()

        # No media data, so actually add a new one
        if media_data is None:
            media_data = self.media_data_table(
                media_entry=self.id,
                **kwargs)
            session.add(media_data)
        # Update old media data
        else:
            for field, value in kwargs.iteritems():
                setattr(media_data, field, value)
开发者ID:orblivion,项目名称:mediagoblin-quickstart-openshift,代码行数:21,代码来源:models_v0.py

示例6: get_all_blog_posts

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
 def get_all_blog_posts(self, state=None):
     blog_posts = Session.query(MediaEntry).join(BlogPostData)\
     .filter(BlogPostData.blog == self.id)
     if state is not None:
         blog_posts = blog_posts.filter(MediaEntry.state==state)
     return blog_posts
开发者ID:ausbin,项目名称:mediagoblin,代码行数:8,代码来源:models.py

示例7: media_data

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import query [as 别名]
    def media_data(self):
        session = Session()

        return session.query(self.media_data_table).filter_by(
            media_entry=self.id).first()
开发者ID:orblivion,项目名称:mediagoblin-quickstart-openshift,代码行数:7,代码来源:models.py


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