Exemple #1
0
    def undoPrincipalTransactions(self, principal, ids):
        """See zope.app.undo.interfaces.IPrincipal"""
        if not IPrincipal.providedBy(principal):
            raise TypeError("Invalid principal: %s" % principal)

        # Make sure we only undo the transactions initiated by our
        # principal
        left_overs = list(ids)
        first = 0
        batch_size = 20
        txns = self._getUndoInfo(None, principal, first, -batch_size)
        while txns and left_overs:
            for info in txns:
                if (info['id'] in left_overs and
                    info['principal'].id == principal.id):
                    left_overs.remove(info['id'])
            first += batch_size
            txns = self._getUndoInfo(None, principal, first, -batch_size)
        if left_overs:
            raise UndoError("You are trying to undo a transaction that "
                            "either does not exist or was not initiated "
                            "by the principal.")
        self._undo(ids)
Exemple #2
0
 def getPrincipalTransactions(self, principal, context=None,
                              first=0, last=-20):
     """See zope.app.undo.interfaces.IPrincipal"""
     if not IPrincipal.providedBy(principal):
         raise TypeError("Invalid principal: %s" % principal)
     return self._getUndoInfo(context, principal, first, last)