Beispiel #1
0
def setUp(test):
    setup.placefulSetUp(True)
    setUpDublinCore()
    component.provideAdapter(storage.Storage)
    component.provideAdapter(AttributeAnnotations)

    hooks.setHooks()
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    setup.setUpTestAsModule(test, 'zojax.content.model.README')

    # generate extension
    ExtensionClass = ExtensionType(
        "content.model",
        IViewModelExtension, ViewModelExtension,
        "View Model", "View model extension.", layer=interface.Interface)

    # register adater
    component.provideAdapter(
        Wrapper(ExtensionClass),
        (interface.Interface, interface.Interface, ExtensionMarker),
        IViewModelExtension)

    # register vocabulary
    getVocabularyRegistry().register(
        'zojax.content.model-list', Models())

    component.provideAdapter(
        Renderer, (IViewModelSupport, interface.Interface),
        interface.Interface, name='index.html')
Beispiel #2
0
def setUp(test):
    setup.placefulSetUp(True)
    component.provideAdapter(storage.Storage)
    component.provideAdapter(AttributeAnnotations)

    hooks.setHooks()
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    setup.setUpTestAsModule(test, 'zojax.extensions.README')
def setUp(test):
    formSetUp(test)
    component.provideAdapter(TestTemplate, name='layout')
    setup.setUpAnnotations()
    setup.setUpDependable()
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    site = setup.rootFolder()
    setup.createSiteManager(site, setsite=True)
    test.globs['site'] = site
Beispiel #4
0
def setUp(test):
    setHooks()
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    site = setup.placefulSetUp(True)
    site.__name__ = u'portal'
    component.provideAdapter(
        PrincipalAnnotations, (IPrincipal,), IAnnotations)
    component.provideAdapter(getMessageStorage)

    setup.setUpTestAsModule(test, name='zojax.messaging.TESTS')
Beispiel #5
0
def setUpControlPanel():
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    
    component.provideAdapter(root.getSettings, name='settings')
    component.provideAdapter(AttributeAnnotations)
    component.provideUtility(root.RootConfiglet(), interfaces.IConfiglet)
    
    component.provideAdapter(storage.getConfigletData)
    component.provideAdapter(storage.getConfigletDataStorage)
    component.provideAdapter(storage.DefaultConfigletDataFactory)
    def setUp(self):
        TestITranslationDomain.setUp(self)

        # placefulSetup
        setup.setUpTraversal()
        setup.setUpSiteManagerLookup()
        self.rootFolder = setup.buildSampleFolderTree()

        self.sm = setup.createSiteManager(self.rootFolder, setsite=True)
        setup.addUtility(self.sm, 'default', ITranslationDomain, self._domain)

        provideUtility(Factory(MessageCatalog), IFactory,
                       'zope.app.MessageCatalog')
Beispiel #7
0
    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 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)