def createRFAndSM(self): cx = self.db.open() root = cx.root() self.root_folder = rootFolder() root[ZopePublication.root_name] = self.root_folder self.site_manager = LocalSiteManager(self.root_folder) self.root_folder.setSiteManager(self.site_manager) sub_folder = Folder() self.root_folder["sub_folder"] = sub_folder sub_site_manager = LocalSiteManager(sub_folder) sub_folder.setSiteManager(sub_site_manager) transaction.commit() cx.close()
def setUp(self): setup.placelessSetUp() provideAdapter(OOBTreeState) provideAdapter(ZodbObjectHistory) RealDatabaseTest.setUp(self) self.folder = self.conn.root()['folder'] = Folder() self.folder['foo'] = 1 self.folder['bar'] = 2 transaction.commit() self.state = FolderState(None, self.folder.__getstate__(), None)
def testPlacefulAuth(self): setup.setUpTraversal() setup.setUpSiteManagerLookup() principalRegistry.defineDefaultPrincipal('anonymous', '') root = self.db.open().root() app = root[ZopePublication.root_name] app['f1'] = rootFolder() f1 = app['f1'] f1['f2'] = Folder() sm1 = setup.createSiteManager(f1) setup.addUtility(sm1, '', IAuthenticationUtility, AuthUtility1()) f2 = f1['f2'] sm2 = setup.createSiteManager(f2) setup.addUtility(sm2, '', IAuthenticationUtility, AuthUtility2()) transaction.commit() from zope.app.container.interfaces import ISimpleReadContainer from zope.app.container.traversal import ContainerTraverser ztapi.provideView(ISimpleReadContainer, IRequest, IPublishTraverse, '', ContainerTraverser) from zope.app.folder.interfaces import IFolder from zope.security.checker import defineChecker, InterfaceChecker defineChecker(Folder, InterfaceChecker(IFolder)) self.publication.beforeTraversal(self.request) self.assertEqual(list(queryInteraction().participations), [self.request]) self.assertEqual(self.request.principal.id, 'anonymous') root = self.publication.getApplication(self.request) self.publication.callTraversalHooks(self.request, root) self.assertEqual(self.request.principal.id, 'anonymous') ob = self.publication.traverseName(self.request, root, 'f1') self.publication.callTraversalHooks(self.request, ob) self.assertEqual(self.request.principal.id, 'test.anonymous') ob = self.publication.traverseName(self.request, ob, 'f2') self.publication.afterTraversal(self.request, ob) self.assertEqual(self.request.principal.id, 'test.bob') self.assertEqual(list(queryInteraction().participations), [self.request]) self.publication.endRequest(self.request, ob) self.assertEqual(queryInteraction(), None)
def __init__(self, **data): """ constructor of the object """ Superclass.__init__(self, **data) Folder.__init__(self)
def test_listItems_no_data(self): state = FolderState(None, Folder().__getstate__(), None) self.assertEqual(list(state.listItems()), [])