コード例 #1
0
ファイル: test_components.py プロジェクト: goschtl/zope
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents()
    components.__bases__ = (base,)
    components.__parent__ = aq_base(context)
    context.setSiteManager(components)
コード例 #2
0
ファイル: test_utility.py プロジェクト: goschtl/zope
    def test_getNextUtility(self):
        # test local site vs. global site
        global_dummy = DummyUtility()
        provideUtility(global_dummy, IDummyUtility)

        local_dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, local_dummy)

        self.assertEquals(zapi.getUtility(IDummyUtility), local_dummy)
        self.assertEquals(getNextUtility(self.folder.site, IDummyUtility),
                          global_dummy)

        # test local site vs. nested local site
        manage_addDummySite(self.folder.site, 'subsite')
        enableSite(self.folder.site.subsite)
        setSite(self.folder.site.subsite)

        sublocal_dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, sublocal_dummy)

        self.assertEquals(zapi.getUtility(IDummyUtility), sublocal_dummy)
        self.assertEquals(getNextUtility(self.folder.site.subsite, IDummyUtility),
                          local_dummy)
        self.assertEquals(getNextUtility(self.folder.site, IDummyUtility),
                          global_dummy)
コード例 #3
0
def setupVarious(context):
    portal = context.getSite()
    if not ISite.providedBy(portal):
        enableSite(portal)
    setupLanguages(portal)
    clearPortlets(portal)
    setupNavigationPortlet(portal)
コード例 #4
0
ファイル: test_utility.py プロジェクト: goschtl/zope
    def test_nestedSitesDontConflictButStillAcquire(self):
        # let's register a dummy utility in the dummy site
        dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, dummy)

        # let's also create a subsite and make that our site
        manage_addDummySite(self.folder.site, 'subsite')
        enableSite(self.folder.site.subsite)
        setSite(self.folder.site.subsite)

        # we should still be able to lookup the original utility from
        # the site one level above
        self.assertEqual(zapi.getUtility(IDummyUtility), dummy)

        # now we register a dummy utility in the subsite and see that
        # its registration doesn't conflict
        subdummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, subdummy)

        # when we look it up we get the more local one now because the
        # more local one shadows the less local one
        self.assertEqual(zapi.getUtility(IDummyUtility), subdummy)

        # getAllUtilitiesFor gives us both the more local and the less
        # local utility (XXX not sure if this is the right semantics
        # for getAllUtilitiesFor)
        self.assertEqual(sets.Set(zapi.getAllUtilitiesRegisteredFor(IDummyUtility)),
                         sets.Set([subdummy, dummy]))

        # getUtilitiesFor will only find one, because the more local
        # one shadows the less local one
        self.assertEqual(list(zapi.getUtilitiesFor(IDummyUtility)),
                         [('', subdummy)])
コード例 #5
0
ファイル: browser.py プロジェクト: goschtl/zope
    def makeSite(self):
        """Convert a possible site to a site"""
        if self.isSite():
            raise ValueError('This is already a site')

        enableSite(self.context)
        return "This object is now a site"
コード例 #6
0
ファイル: browser.py プロジェクト: bendavis78/zope
    def makeSite(self):
        """Convert a possible site to a site"""
        if self.isSite():
            raise ValueError('This is already a site')

        enableSite(self.context)
        return "This object is now a site"
コード例 #7
0
    def test_getNextUtility(self):
        # test local site vs. global site
        global_dummy = DummyUtility()
        provideUtility(global_dummy, IDummyUtility)

        local_dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, local_dummy)

        self.assertEquals(zapi.getUtility(IDummyUtility), local_dummy)
        self.assertEquals(getNextUtility(self.folder.site, IDummyUtility),
                          global_dummy)

        # test local site vs. nested local site
        manage_addDummySite(self.folder.site, 'subsite')
        enableSite(self.folder.site.subsite)
        setSite(self.folder.site.subsite)

        sublocal_dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, sublocal_dummy)

        self.assertEquals(zapi.getUtility(IDummyUtility), sublocal_dummy)
        self.assertEquals(
            getNextUtility(self.folder.site.subsite, IDummyUtility),
            local_dummy)
        self.assertEquals(getNextUtility(self.folder.site, IDummyUtility),
                          global_dummy)
コード例 #8
0
ファイル: test_components.py プロジェクト: bendavis78/zope
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents()
    components.__bases__ = (base, )
    components.__parent__ = aq_base(context)
    context.setSiteManager(components)
コード例 #9
0
ファイル: localsite.py プロジェクト: goschtl/zope
def enableLocalSiteHook(obj):
    warnings.warn("The enableLocalSiteHook is deprecated and will be removed "
                  "in Zope 2.12. \nSee Five/doc/localsite.txt .",
                  DeprecationWarning, 2)
    enableSite(obj)
    components = FiveSiteManager(obj)
    obj.setSiteManager(components)
    setSite(obj)
    setHooks()
コード例 #10
0
def enableLocalSiteHook(obj):
    warnings.warn("The enableLocalSiteHook is deprecated and will be removed "
                  "in Zope 2.12. \nSee Five/doc/localsite.txt .",
                  DeprecationWarning, 2)
    enableSite(obj)
    components = FiveSiteManager(obj)
    obj.setSiteManager(components)
    setSite(obj)
    setHooks()
コード例 #11
0
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents('++etc++site')
    components.__bases__ = (base, )
    components.__parent__ = aq_base(context)
    # Make sure calls to getSiteManager on me return myself
    # necessary because OFS.ObjectManager.getSiteManager expects _components
    components._components = components
    context.setSiteManager(components)
コード例 #12
0
ファイル: test_components.py プロジェクト: pigaov10/plone4.3
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents('++etc++site')
    components.__bases__ = (base,)
    components.__parent__ = aq_base(context)
    # Make sure calls to getSiteManager on me return myself
    # necessary because OFS.ObjectManager.getSiteManager expects _components
    components._components = components
    context.setSiteManager(components)
コード例 #13
0
ファイル: browser.py プロジェクト: goschtl/zope
    def makeSite(self):
        if IObjectManagerSite.providedBy(self.context):
            raise ValueError('This is already a site')

        enableSite(self.context, iface=IObjectManagerSite)

        #TODO in the future we'll have to walk up to other site
        # managers and put them in the bases
        components = PersistentComponents()
        components.__bases__ = (base,)
        self.context.setSiteManager(components)
コード例 #14
0
    def makeSite(self):
        if IObjectManagerSite.providedBy(self.context):
            raise ValueError('This is already a site')

        enableSite(self.context, iface=IObjectManagerSite)

        #TODO in the future we'll have to walk up to other site
        # managers and put them in the bases
        components = PersistentComponents()
        components.__bases__ = (base,)
        self.context.setSiteManager(components)
コード例 #15
0
def enable_local_site(obj):
    enableSite(obj, iface=IObjectManagerSite)
    for parent in aq_chain(obj)[1:]:
        if ISite.providedBy(parent):
            p_sm = parent.getSiteManager()
            bases = (p_sm, ) + p_sm.__bases__
            break
    else:
        bases = (base, )
    components = PersistentComponents()
    components.__bases__ = bases
    obj.setSiteManager(components)
コード例 #16
0
def enable_local_site(obj):
    enableSite(obj, iface=IObjectManagerSite)
    for parent in aq_chain(obj)[1:]:
        if ISite.providedBy(parent):
            p_sm = parent.getSiteManager()
            bases = (p_sm,) + p_sm.__bases__
            break
    else:
         bases = (base,)   
    components = PersistentComponents()
    components.__bases__ = bases
    obj.setSiteManager(components)
コード例 #17
0
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')

    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    components = PersistentComponents('++etc++site', bases=(next,))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
コード例 #18
0
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')

    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    components = PersistentComponents('++etc++site', bases=(next, ))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
コード例 #19
0
def install(context):
    portal = context.getSite()
    if not 'fr' in portal.objectIds():
        raise Warning("You must first go to .../plone/@@language-setup-folders")
    if not ISite.providedBy(portal):
        enableSite(portal)
    deleteFolder(portal, 'news')
    deleteFolder(portal, 'events')
    deleteFolder(portal, 'Members')
    setupLanguages(portal)
    # Don't touch portlets anymore since manual changes have been made TTW
    # clearPortlets(portal)
    # setupNavigationPortlet(portal)
    # setupNavigation(portal)
    setupLinkIntegrityCheck(portal)
    addRoles(portal)
    activatePloneLDAPPlugin(portal)
    addMemberProperty(portal)
コード例 #20
0
ファイル: test_utility.py プロジェクト: goschtl/zope
    def afterSetUp(self):
        setUp()
        zcml.load_config("meta.zcml", Products.Five)
        zcml.load_config("permissions.zcml", Products.Five)
        zcml.load_config("configure.zcml", Products.Five.component)
        zcml.load_config("configure.zcml", Products.Five.site)
        zcml_text = """\
        <five:localsite
            xmlns:five="http://namespaces.zope.org/five"
            class="Products.Five.site.tests.dummy.DummySite" />"""
        zcml.load_string(zcml_text)
        manage_addDummySite(self.folder, 'site')
        enableSite(self.folder.site)
        setSite(self.folder.site)

        # Hook up custom component architecture calls; we need to do
        # this here because zope.app.component.hooks registers a
        # cleanup with the testing cleanup framework, so the hooks get
        # torn down by placelesssetup each time.
        setHooks()
コード例 #21
0
    def afterSetUp(self):
        setUp()
        zcml.load_config("meta.zcml", Products.Five)
        zcml.load_config("permissions.zcml", Products.Five)
        zcml.load_config("configure.zcml", Products.Five.component)
        zcml.load_config("configure.zcml", Products.Five.site)
        zcml_text = """\
        <five:localsite
            xmlns:five="http://namespaces.zope.org/five"
            class="Products.Five.site.tests.dummy.DummySite" />"""
        zcml.load_string(zcml_text)
        manage_addDummySite(self.folder, 'site')
        enableSite(self.folder.site)
        setSite(self.folder.site)

        # Hook up custom component architecture calls; we need to do
        # this here because zope.app.component.hooks registers a
        # cleanup with the testing cleanup framework, so the hooks get
        # torn down by placelesssetup each time.
        setHooks()
コード例 #22
0
ファイル: __init__.py プロジェクト: dtgit/dtedu
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')
    
    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    name = 'five'
    path = getattr(obj, 'getPhysicalPath', None)
    if path is not None and callable(path):
        name = '/'.join(path())

    components = PersistentComponents(name=name, bases=(next,))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
コード例 #23
0
    def test_nestedSitesDontConflictButStillAcquire(self):
        # let's register a dummy utility in the dummy site
        dummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, dummy)

        # let's also create a subsite and make that our site
        manage_addDummySite(self.folder.site, 'subsite')
        enableSite(self.folder.site.subsite)
        setSite(self.folder.site.subsite)

        # we should still be able to lookup the original utility from
        # the site one level above
        self.assertEqual(zapi.getUtility(IDummyUtility), dummy)

        # now we register a dummy utility in the subsite and see that
        # its registration doesn't conflict
        subdummy = DummyUtility()
        sm = zapi.getSiteManager()
        sm.registerUtility(IDummyUtility, subdummy)

        # when we look it up we get the more local one now because the
        # more local one shadows the less local one
        self.assertEqual(zapi.getUtility(IDummyUtility), subdummy)

        # getAllUtilitiesFor gives us both the more local and the less
        # local utility (XXX not sure if this is the right semantics
        # for getAllUtilitiesFor)
        self.assertEqual(
            sets.Set(zapi.getAllUtilitiesRegisteredFor(IDummyUtility)),
            sets.Set([subdummy, dummy]))

        # getUtilitiesFor will only find one, because the more local
        # one shadows the less local one
        self.assertEqual(list(zapi.getUtilitiesFor(IDummyUtility)),
                         [('', subdummy)])
コード例 #24
0
def setupgdwdoc(context):
    logger.debug('Setup gdwdoc skin')
    portal = context.getSite()
    if not ISite.providedBy(portal):
        enableSite(portal)
    activatePloneLDAPPlugin(portal)
コード例 #25
0
def setupAffinitic(context):
    logger.debug('Setup Affinitic skin')
    portal = context.getSite()
    if not ISite.providedBy(portal):
        enableSite(portal)