def get_principal(self, id): try: return principalRegistry.getPrincipal(id) except PrincipalLookupError: pass except KeyError: pass
def get_principal(self, id): try: return principalRegistry.getPrincipal(id) except PrincipalLookupError: pass except KeyError: pass
def testUndoPrincipalTransactions(self): request = self.request bonobo = principalRegistry.getPrincipal('bonobo') request.setPrincipal(bonobo) view = UndoView(self.folder1, request) # Just test whether it accepts the principal. We know that # our undo dummy above "works". self.undo._emulatePublication(request) view.undoPrincipalTransactions(['6']) self.assert_(self.undo.principal is bonobo)
def testPrincipalLastTransactionIsUndo(self): request = self.request bonobo = principalRegistry.getPrincipal('bonobo') request.setPrincipal(bonobo) view = UndoView(self.folder1, request) self.failIf(view.principalLastTransactionIsUndo()) # now undo the last transaction self.undo._emulatePublication(request) self.undo.undoTransactions(['6']) self.assert_(view.principalLastTransactionIsUndo())
def testUndoPrincipalLastTransaction(self): request = self.request bonobo = principalRegistry.getPrincipal('bonobo') request.setPrincipal(bonobo) self.undo._emulatePublication(request) view = UndoView(self.folder1, request) view.undoPrincipalLastTransaction() last_txn = self.undo.getTransactions(None, 0, 1)[0] self.assert_(last_txn.has_key('undo')) self.assert_(last_txn['undo']) self.assertEqual(last_txn['user_name'], bonobo.id)
def testGetPrincipalTransactions(self): request = self.request bonobo = principalRegistry.getPrincipal('bonobo') request.setPrincipal(bonobo) view = UndoView(self.folder1, request) expected = self.undo.getPrincipalTransactions(bonobo) self.assertEqual(view.getPrincipalTransactions(), expected) self.assert_(self.undo.context is self.folder1) self.assert_(self.undo.principal is bonobo) # test showall parameter and principal self.undo.principal = None view.getPrincipalTransactions(showall=True) self.assert_(self.undo.context is None) self.assert_(self.undo.principal is bonobo)
def principalInfo(self, id): principal = principalRegistry.getPrincipal(id) if principal is not None: return PrincipalInfo(u'' + principal.id, principal.getLogin(), principal.title, principal.description)