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


Python IStore.with_方法代码示例

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


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

示例1: getFlattenedOverlayTree

# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import with_ [as 别名]
 def getFlattenedOverlayTree(self, derived_series):
     """See `IDistroSeriesParentSet`."""
     self.getByDerivedSeries(derived_series)
     rec_overlay_query = '''
         RECURSIVE t_parents(parent_series) AS (
             SELECT parent_series
             FROM DistroSeriesParent
             WHERE derived_series=? AND
                 is_overlay = True
         UNION ALL
             SELECT dsp.parent_series
             FROM DistroSeriesParent dsp, t_parents p
             WHERE dsp.derived_series = p.parent_series AND
                 dsp.is_overlay = True
     ) '''
     store = IStore(DistroSeriesParent)
     # XXX: rvb 2011-05-20 bug=785733: Order by DSD.id for now.
     # Once the ordering is specified in the database, it should
     # be used to sort the results.
     return store.with_(
         SQL(rec_overlay_query, (derived_series.id, ))).find(
             DistroSeriesParent,
             SQL('DistroSeriesParent.parent_series IN '
                 '(SELECT parent_series FROM t_parents)')
             ).order_by(DistroSeriesParent.id)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:27,代码来源:distroseriesparent.py

示例2: _getSharedPillars

# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import with_ [as 别名]
    def _getSharedPillars(self, person, user, pillar_class, extra_filter=None):
        """Helper method for getSharedProjects and getSharedDistributions.

        pillar_class is either Product or Distribution. Products define the
        owner foreign key attribute as _owner so we need to account for that,
        but otherwise the logic is the same for both pillar types.
        """
        if user is None:
            return []
        store = IStore(AccessPolicyGrantFlat)
        roles = IPersonRoles(user)
        if roles.in_admin:
            filter = True
        else:
            with_statement = With("teams",
                Select(TeamParticipation.teamID,
                    tables=TeamParticipation,
                    where=TeamParticipation.person == user.id))
            teams_sql = SQL("SELECT team from teams")
            store = store.with_(with_statement)
            if IProduct.implementedBy(pillar_class):
                ownerID = pillar_class._ownerID
            else:
                ownerID = pillar_class.ownerID
            filter = Or(
                extra_filter or False,
                ownerID.is_in(teams_sql),
                pillar_class.driverID.is_in(teams_sql))
        tables = [
            AccessPolicyGrantFlat,
            Join(
                AccessPolicy,
                AccessPolicyGrantFlat.policy_id == AccessPolicy.id)]
        if IProduct.implementedBy(pillar_class):
            access_policy_column = AccessPolicy.product_id
        else:
            access_policy_column = AccessPolicy.distribution_id
        result_set = store.find(
            pillar_class,
            pillar_class.id.is_in(
                Select(
                    columns=access_policy_column, tables=tables,
                    where=(AccessPolicyGrantFlat.grantee_id == person.id))
            ), filter)
        return result_set
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:47,代码来源:sharingservice.py

示例3: load_teams_and_permissions

# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import with_ [as 别名]
        def load_teams_and_permissions(grantees):
            # We now have the grantees we want in the result so load any
            # associated team memberships and permissions and cache them.
            if permissions_cache:
                return
            store = IStore(cls)
            for grantee in grantees:
                grantees_by_id[grantee[0].id] = grantee[0]
            # Find any teams associated with the grantees. If grantees is a
            # sliced list (for batching), it may contain indirect grantees but
            # not the team they belong to so that needs to be fixed below.
            with_expr = With("grantees", store.find(
                cls.grantee_id, cls.policy_id.is_in(policies_by_id.keys())
                ).config(distinct=True)._get_select())
            result_set = store.with_(with_expr).find(
                (TeamParticipation.teamID, TeamParticipation.personID),
                TeamParticipation.personID.is_in(grantees_by_id.keys()),
                TeamParticipation.teamID.is_in(
                    Select(
                        (SQL("grantees.grantee"),),
                        tables="grantees",
                        distinct=True)))
            team_ids = set()
            direct_grantee_ids = set()
            for team_id, team_member_id in result_set:
                if team_member_id == team_id:
                    direct_grantee_ids.add(team_member_id)
                else:
                    via_teams_cache[team_member_id].append(team_id)
                    team_ids.add(team_id)
            # Remove from the via_teams cache all the direct grantees.
            for direct_grantee_id in direct_grantee_ids:
                if direct_grantee_id in via_teams_cache:
                    del via_teams_cache[direct_grantee_id]
            # Load and cache the additional required teams.
            persons = store.find(Person, Person.id.is_in(team_ids))
            for person in persons:
                grantees_by_id[person.id] = person

            cls._populatePermissionsCache(
                permissions_cache, shared_artifact_info_types,
                grantees_by_id.keys(), policies_by_id, grantees_by_id)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:44,代码来源:accesspolicy.py


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