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


Python Session.query方法代码示例

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


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

示例1: get_default_perms

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def get_default_perms(cls, default_user_id):
        q = Session.query(UserRepoToPerm, Repository, cls)\
         .join((Repository, UserRepoToPerm.repository_id == Repository.repo_id))\
         .join((cls, UserRepoToPerm.permission_id == cls.permission_id))\
         .filter(UserRepoToPerm.user_id == default_user_id)

        return q.all()
开发者ID:msabramo,项目名称:kallithea,代码行数:9,代码来源:db_1_3_0.py

示例2: get_default_group_perms

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def get_default_group_perms(cls, default_user_id):
        q = Session.query(UserRepoGroupToPerm, RepoGroup, cls)\
         .join((RepoGroup, UserRepoGroupToPerm.group_id == RepoGroup.group_id))\
         .join((cls, UserRepoGroupToPerm.permission_id == cls.permission_id))\
         .filter(UserRepoGroupToPerm.user_id == default_user_id)

        return q.all()
开发者ID:msabramo,项目名称:kallithea,代码行数:9,代码来源:db_1_3_0.py

示例3: repo_path

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
 def repo_path(self):
     """
     Returns base full path for that repository means where it actually
     exists on a filesystem
     """
     q = Session.query(Ui).filter(Ui.ui_key ==
                                           Repository.url_sep())
     q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
     return q.one().ui_value
开发者ID:msabramo,项目名称:kallithea,代码行数:11,代码来源:db_1_3_0.py

示例4: base_path

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def base_path(cls):
        """
        Returns base path when all repos are stored

        :param cls:
        """
        q = Session.query(Ui)\
            .filter(Ui.ui_key == cls.url_sep())
        q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
        return q.one().ui_value
开发者ID:msabramo,项目名称:kallithea,代码行数:12,代码来源:db_1_3_0.py

示例5: _get_or_create_key

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
 def _get_or_create_key(cls, key, prefix, org_key):
     inv_obj = Session.query(cls).filter(cls.cache_key == key).scalar()
     if not inv_obj:
         try:
             inv_obj = CacheInvalidation(key, org_key)
             Session.add(inv_obj)
             Session.commit()
         except Exception:
             log.error(traceback.format_exc())
             Session.rollback()
     return inv_obj
开发者ID:msabramo,项目名称:kallithea,代码行数:13,代码来源:db_1_3_0.py

示例6: get_users

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def get_users(cls, revision):
        """
        Returns user associated with this changesetComment. ie those
        who actually commented

        :param cls:
        :param revision:
        """
        return Session.query(User)\
                .filter(cls.revision == revision)\
                .join(ChangesetComment.author).all()
开发者ID:msabramo,项目名称:kallithea,代码行数:13,代码来源:db_1_3_0.py

示例7: set_valid

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def set_valid(cls, key):
        """
        Mark this cache key as active and currently cached

        :param key:
        """
        inv_obj = Session.query(CacheInvalidation)\
            .filter(CacheInvalidation.cache_key == key).scalar()
        inv_obj.cache_active = True
        Session.add(inv_obj)
        Session.commit()
开发者ID:msabramo,项目名称:kallithea,代码行数:13,代码来源:db_1_2_0.py

示例8: set_invalidate

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def set_invalidate(cls, key):
        """
        Mark this Cache key for invalidation

        :param key:
        """

        key, _prefix, _org_key = cls._get_key(key)
        inv_objs = Session.query(cls).filter(cls.cache_args == _org_key).all()
        log.debug('marking %s key[s] %s for invalidation' % (len(inv_objs),
                                                             _org_key))
        try:
            for inv_obj in inv_objs:
                if inv_obj:
                    inv_obj.cache_active = False

                Session.add(inv_obj)
            Session.commit()
        except Exception:
            log.error(traceback.format_exc())
            Session.rollback()
开发者ID:msabramo,项目名称:kallithea,代码行数:23,代码来源:db_1_3_0.py

示例9: set_invalidate

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
    def set_invalidate(cls, key):
        """
        Mark this Cache key for invalidation

        :param key:
        """

        log.debug('marking %s for invalidation' % key)
        inv_obj = Session.query(cls)\
            .filter(cls.cache_key == key).scalar()
        if inv_obj:
            inv_obj.cache_active = False
        else:
            log.debug('cache key not found in invalidation db -> creating one')
            inv_obj = CacheInvalidation(key)

        try:
            Session.add(inv_obj)
            Session.commit()
        except Exception:
            log.error(traceback.format_exc())
            Session.rollback()
开发者ID:msabramo,项目名称:kallithea,代码行数:24,代码来源:db_1_2_0.py

示例10: get_by_repo_name

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
 def get_by_repo_name(cls, repo_name):
     q = Session.query(cls).filter(cls.repo_name == repo_name)
     q = q.options(joinedload(Repository.fork))\
             .options(joinedload(Repository.user))\
             .options(joinedload(Repository.group))
     return q.scalar()
开发者ID:msabramo,项目名称:kallithea,代码行数:8,代码来源:db_1_3_0.py

示例11: query

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
 def query(cls):
     return Session.query(cls)
开发者ID:msabramo,项目名称:kallithea,代码行数:4,代码来源:db_1_3_0.py

示例12: DbManage

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]

#.........这里部分代码省略.........
            api.version_control(db_uri, repository_path, curr_version)

        notify(msg)
        if curr_version == __dbversion__:
            print 'This database is already at the newest version'
            sys.exit(0)

        # clear cache keys
        log.info("Clearing cache keys now...")
        CacheInvalidation.clear_cache()

        upgrade_steps = range(curr_version + 1, __dbversion__ + 1)
        notify('attempting to do database upgrade from '
               'version %s to version %s' % (curr_version, __dbversion__))

        # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE
        _step = None
        for step in upgrade_steps:
            notify('performing upgrade step %s' % step)
            time.sleep(0.5)

            api.upgrade(db_uri, repository_path, step)
            notify('schema upgrade for step %s completed' % (step,))

            _step = step

        notify('upgrade to version %s successful' % _step)

    def fix_repo_paths(self):
        """
        Fixes a old kallithea version path into new one without a '*'
        """

        paths = self.sa.query(Ui)\
                .filter(Ui.ui_key == '/')\
                .scalar()

        paths.ui_value = paths.ui_value.replace('*', '')

        self.sa.add(paths)
        self.sa.commit()

    def fix_default_user(self):
        """
        Fixes a old default user with some 'nicer' default values,
        used mostly for anonymous access
        """
        def_user = self.sa.query(User)\
                .filter(User.username == User.DEFAULT_USER)\
                .one()

        def_user.name = 'Anonymous'
        def_user.lastname = 'User'
        def_user.email = '[email protected]'

        self.sa.add(def_user)
        self.sa.commit()

    def fix_settings(self):
        """
        Fixes kallithea settings adds ga_code key for google analytics
        """

        hgsettings3 = Setting('ga_code', '')

        self.sa.add(hgsettings3)
开发者ID:msabramo,项目名称:kallithea,代码行数:70,代码来源:db_manage.py

示例13: get_by_username

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import query [as 别名]
 def get_by_username(cls, username, case_insensitive=False):
     if case_insensitive:
         return Session.query(cls).filter(cls.username.ilike(username)).scalar()
     else:
         return Session.query(cls).filter(cls.username == username).scalar()
开发者ID:msabramo,项目名称:kallithea,代码行数:7,代码来源:db_1_2_0.py


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