예제 #1
0
    def powerupsFor(self, interface):
        """
        Returns powerups installed using C{powerUp}, in order of descending
        priority.

        Powerups found to have been deleted, either during the course of this
        powerupsFor iteration, during an upgrader, or previously, will not be
        returned.
        """
        inMemoryPowerup = self._inMemoryPowerups.get(interface, None)
        if inMemoryPowerup is not None:
            yield inMemoryPowerup
        name = unicode(qual(interface), 'ascii')
        for cable in self.store.query(
                _PowerupConnector,
                AND(_PowerupConnector.interface == name,
                    _PowerupConnector.item == self),
                sort=_PowerupConnector.priority.descending):
            pup = cable.powerup
            if pup is None:
                # this powerup was probably deleted during an upgrader.
                cable.deleteFromStore()
            else:
                indirector = IPowerupIndirector(pup, None)
                if indirector is not None:
                    yield indirector.indirect(interface)
                else:
                    yield pup
예제 #2
0
파일: item.py 프로젝트: bne/squeal
    def powerupsFor(self, interface):
        """
        Returns powerups installed using C{powerUp}, in order of descending
        priority.

        Powerups found to have been deleted, either during the course of this
        powerupsFor iteration, during an upgrader, or previously, will not be
        returned.
        """
        inMemoryPowerup = self._inMemoryPowerups.get(interface, None)
        if inMemoryPowerup is not None:
            yield inMemoryPowerup
        name = unicode(qual(interface), 'ascii')
        for cable in self.store.query(
            _PowerupConnector,
            AND(_PowerupConnector.interface == name,
                _PowerupConnector.item == self),
            sort=_PowerupConnector.priority.descending):
            pup = cable.powerup
            if pup is None:
                # this powerup was probably deleted during an upgrader.
                cable.deleteFromStore()
            else:
                indirector = IPowerupIndirector(pup, None)
                if indirector is not None:
                    yield indirector.indirect(interface)
                else:
                    yield pup
예제 #3
0
파일: item.py 프로젝트: perkinslr/axiom-py3
    def powerupsFor(self, interface, tables=(), comparison=None):
        """
        Returns powerups installed using C{powerUp}, in order of descending
        priority.

        Powerups found to have been deleted, either during the course of this
        powerupsFor iteration, during an upgrader, or previously, will not be
        returned.
        """
        inMemoryPowerup = self._inMemoryPowerups.get(interface, [])
        for pup in inMemoryPowerup:
            yield pup
        if self.store is None:
            return

        name = qual(interface)

        tables = (_PowerupConnector, ) + tables
        if comparison:
            comparison = AND(_PowerupConnector.interface == name,
                             _PowerupConnector.item == self,
                             _PowerupConnector.powerup == tables[1].storeID,
                             comparison)
        else:
            comparison = AND(
                _PowerupConnector.interface == name,
                _PowerupConnector.item == self,
            )

        q = self.store.query(
            tables, comparison,
            sort=_PowerupConnector.priority.descending).distinct()

        for entries in q:
            cable = entries[0]
            pup = cable.powerup
            if pup is None:
                # this powerup was probably deleted during an upgrader.
                cable.deleteFromStore()
            else:
                indirector = IPowerupIndirector(pup, None)
                if indirector is not None:
                    yield indirector.indirect(interface)
                else:
                    yield pup
예제 #4
0
파일: item.py 프로젝트: perkinslr/axiom-py3
    def powerupsFor(self, interface, tables=(), comparison=None):
        """
        Returns powerups installed using C{powerUp}, in order of descending
        priority.

        Powerups found to have been deleted, either during the course of this
        powerupsFor iteration, during an upgrader, or previously, will not be
        returned.
        """
        inMemoryPowerup = self._inMemoryPowerups.get(interface, [])
        for pup in inMemoryPowerup:
            yield pup
        if self.store is None:
            return

        name = qual(interface)

        tables = (_PowerupConnector,) + tables
        if comparison:
            comparison = AND(
                _PowerupConnector.interface == name,
                _PowerupConnector.item == self,
                _PowerupConnector.powerup == tables[1].storeID,
                comparison,
            )
        else:
            comparison = AND(_PowerupConnector.interface == name, _PowerupConnector.item == self)

        q = self.store.query(tables, comparison, sort=_PowerupConnector.priority.descending).distinct()

        for entries in q:
            cable = entries[0]
            pup = cable.powerup
            if pup is None:
                # this powerup was probably deleted during an upgrader.
                cable.deleteFromStore()
            else:
                indirector = IPowerupIndirector(pup, None)
                if indirector is not None:
                    yield indirector.indirect(interface)
                else:
                    yield pup