Exemplo n.º 1
0
    def checkAuthenticated(self,
                           person,
                           archive,
                           permission,
                           item,
                           distroseries=None):
        """See `IArchivePermissionSet`."""
        clauses = [
            """
            ArchivePermission.archive = %s AND
            ArchivePermission.permission = %s AND
            ArchivePermission.person = TeamParticipation.team AND
            TeamParticipation.person = %s
            """ % sqlvalues(archive, permission, person)
        ]

        prejoins = []

        if IComponent.providedBy(item):
            clauses.append("ArchivePermission.component = %s" %
                           sqlvalues(item))
            prejoins.append("component")
        elif ISourcePackageName.providedBy(item):
            clauses.append("ArchivePermission.sourcepackagename = %s" %
                           sqlvalues(item))
            prejoins.append("sourcepackagename")
        elif IPackageset.providedBy(item):
            clauses.append("ArchivePermission.packageset = %s" %
                           sqlvalues(item.id))
            prejoins.append("packageset")
        elif (zope_isinstance(item, DBItem)
              and item.enum.name == "PackagePublishingPocket"):
            clauses.append("ArchivePermission.pocket = %s" % sqlvalues(item))
            if distroseries is not None:
                clauses.append("(ArchivePermission.distroseries IS NULL OR "
                               "ArchivePermission.distroseries = %s)" %
                               sqlvalues(distroseries))
                prejoins.append("distroseries")
        else:
            raise AssertionError(
                "'item' %r is not an IComponent, IPackageset, "
                "ISourcePackageName or PackagePublishingPocket" % item)

        query = " AND ".join(clauses)
        auth = ArchivePermission.select(query,
                                        clauseTables=["TeamParticipation"],
                                        prejoins=prejoins)

        return auth
Exemplo n.º 2
0
    def checkAuthenticated(self, person, archive, permission, item,
                           distroseries=None):
        """See `IArchivePermissionSet`."""
        clauses = ["""
            ArchivePermission.archive = %s AND
            ArchivePermission.permission = %s AND
            ArchivePermission.person = TeamParticipation.team AND
            TeamParticipation.person = %s
            """ % sqlvalues(archive, permission, person)]

        prejoins = []

        if IComponent.providedBy(item):
            clauses.append(
                "ArchivePermission.component = %s" % sqlvalues(item))
            prejoins.append("component")
        elif ISourcePackageName.providedBy(item):
            clauses.append(
                "ArchivePermission.sourcepackagename = %s" % sqlvalues(item))
            prejoins.append("sourcepackagename")
        elif IPackageset.providedBy(item):
            clauses.append(
                "ArchivePermission.packageset = %s" % sqlvalues(item.id))
            prejoins.append("packageset")
        elif (zope_isinstance(item, DBItem) and
              item.enum.name == "PackagePublishingPocket"):
            clauses.append("ArchivePermission.pocket = %s" % sqlvalues(item))
            if distroseries is not None:
                clauses.append(
                    "(ArchivePermission.distroseries IS NULL OR "
                     "ArchivePermission.distroseries = %s)" %
                    sqlvalues(distroseries))
                prejoins.append("distroseries")
        else:
            raise AssertionError(
                "'item' %r is not an IComponent, IPackageset, "
                "ISourcePackageName or PackagePublishingPocket" % item)

        query = " AND ".join(clauses)
        auth = ArchivePermission.select(
            query, clauseTables=["TeamParticipation"],
            prejoins=prejoins)

        return auth
Exemplo n.º 3
0
 def _nameToPackageset(self, packageset):
     """Helper to convert a possible string name to IPackageset."""
     if isinstance(packageset, basestring):
         # A package set name was passed, assume the current distro series.
         ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
         name = packageset
         store = IStore(Packageset)
         packageset = store.find(Packageset,
                                 name=name,
                                 distroseries=ubuntu.currentseries).one()
         if packageset is not None:
             return packageset
         else:
             raise NotFoundError("No such package set '%s'" % name)
     elif IPackageset.providedBy(packageset):
         return packageset
     else:
         raise ValueError('Not a package set: %s' %
                          _extract_type_name(packageset))
Exemplo n.º 4
0
 def _nameToPackageset(self, packageset):
     """Helper to convert a possible string name to IPackageset."""
     if isinstance(packageset, basestring):
         # A package set name was passed, assume the current distro series.
         ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
         name = packageset
         store = IStore(Packageset)
         packageset = store.find(
             Packageset, name=name,
             distroseries=ubuntu.currentseries).one()
         if packageset is not None:
             return packageset
         else:
             raise NotFoundError("No such package set '%s'" % name)
     elif IPackageset.providedBy(packageset):
         return packageset
     else:
         raise ValueError(
             'Not a package set: %s' % _extract_type_name(packageset))