Ejemplo n.º 1
0
    def setUp(self):
        setup.placefulSetUp()
        self.rootFolder = setup.buildSampleFolderTree()
        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        de_catalog.setMessage('long_greeting', 'Guten Tag!', 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain('default')
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, 'default')

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = 'default'
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo Welt!', 10)
        td['de-default-1'] = de_catalog

        mgr = setup.createSiteManager(traverse(self.rootFolder, 'folder1'))
        setup.addUtility(
            mgr, 'default', interfaces.ILocalTranslationDomain, td)

        self.trans1 = td
        self.trans = domain
Ejemplo n.º 2
0
    def setUp(self):
        setup.placefulSetUp()
        self.rootFolder = setup.buildSampleFolderTree()
        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo!", 10)
        de_catalog.setMessage("long_greeting", "Guten Tag!", 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain("default")
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, "default")

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = "default"
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo Welt!", 10)
        td["de-default-1"] = de_catalog

        mgr = setup.createSiteManager(traverse(self.rootFolder, "folder1"))
        setup.addUtility(mgr, "default", interfaces.ILocalTranslationDomain, td)

        self.trans1 = td
        self.trans = domain
Ejemplo n.º 3
0
    def setUp(self):
        classImplements(TranslationDomain, IAttributeAnnotatable)
        self.sm = PlacefulSetup.setUp(self, site=True)
        TestITranslationDomain.setUp(self)

        setup.addUtility(self.sm, "default", ITranslationDomain, self._domain)

        ztapi.provideUtility(IFactory, Factory(MessageCatalog), "zope.app.MessageCatalog")
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    def setUp(self):
        from zope.app.folder import Folder, rootFolder

        ReferenceSetupMixin.setUp(self)

        sm = zapi.getSiteManager(self.root)
        self.utility = setup.addUtility(sm, '1', IIntIds, IntIds())

        self.root['folder1'] = Folder()
        self.root._p_jar = ConnectionStub()
        self.root['folder1']['folder1_1'] = self.folder1_1 = Folder()
        self.root['folder1']['folder1_1']['folder1_1_1'] = Folder()

        sm1_1 = setup.createSiteManager(self.folder1_1)
        self.utility1 = setup.addUtility(sm1_1, '2', IIntIds, IntIds())
Ejemplo n.º 6
0
    def setUp(self):
        BrowserTestCase.setUp(self)

        self.basepath = '/++etc++site/default'
        root = self.getRootFolder()

        sm = traverse(root, '/++etc++site')
        setup.addUtility(sm, 'intid', IIntIds, IntIds())
        commit()

        type_name = 'BrowserAdd__zope.intid.IntIds'

        response = self.publish(
            self.basepath + '/contents.html',
            basic='mgr:mgrpw',
            form={'type_name': type_name,
                  'new_value': 'mgr' })
Ejemplo n.º 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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def setUp(self):
        BrowserTestCase.setUp(self)

        self.basepath = '/++etc++site/default'
        root = self.getRootFolder()

        sm = traverse(root, '/++etc++site')
        setup.addUtility(sm, 'intid', IIntIds, IntIds())
        commit()

        type_name = 'BrowserAdd__zope.intid.IntIds'

        response = self.publish(self.basepath + '/contents.html',
                                basic='mgr:mgrpw',
                                form={
                                    'type_name': type_name,
                                    'new_value': 'mgr'
                                })
Ejemplo n.º 10
0
    def testGetFromLayered(self):
        princeSomebody = Principal("somebody")
        sm1 = self.makeSite("folder1")
        subUtil = setup.addUtility(sm1, "", IPrincipalAnnotationUtility, PrincipalAnnotationUtility())

        parentAnnotation = self.util.getAnnotations(princeSomebody)

        # Just getting doesn't actualy store. We don't want to store unless
        # we make a change.
        self.assert_(not subUtil.hasAnnotations(princeSomebody))

        parentAnnotation["hair_color"] = "blue"

        # But now we should have the annotation:
        self.assert_(self.util.hasAnnotations(princeSomebody))

        subAnnotation = subUtil.getAnnotations(princeSomebody)
        self.assertEquals(subAnnotation["hair_color"], "blue")

        subAnnotation["foo"] = "bar"

        self.assertEquals(parentAnnotation.get("foo"), None)