def test_migration_preserves_references(self):
        portal = self.layer['portal']
        z2.login(portal['acl_users'], 'manager')
        portal.invokeFactory("Child Folder", "cf1")
        cf1 = portal.cf1
        cf1.setTitle("CF 1")
        make_objectmanager_site(cf1)
        pw = portal.portal_workflow
        pw.doActionFor(cf1, "publish")
        self.failUnless(cf1.Title() == "CF 1")
        self.failUnless(pw.getInfoFor(cf1, "review_state") == "published")
        self.failUnless(ISite.providedBy(cf1))

        cf1.invokeFactory("Document", "doc1", Title="Doc 1")
        doc1 = cf1["doc1"]
        cf1.setDefaultPage("doc1")

        doc2_text = (
            '<p><a href="resolveuid/%s" class="internal">Link to doc 1'
            '</a></p>') % doc1.UID()
        cf1.invokeFactory("Document", "doc2", Title="Doc 2", text=doc2_text)
        doc2 = cf1["doc2"]
        # I'm not sure what layer of Plone code adds these
        doc2.addReference(doc1, 'isReferencing', updateReferences=True)
        self.assertEquals(
            len(doc2._getReferenceAnnotations().objectItems()), 1)

        self.run_migration_step()

        cf1 = portal.cf1
        doc2 = cf1["doc2"]
        self.assertEquals(
            len(doc2._getReferenceAnnotations().objectItems()), 1)
Пример #2
0
def setEROSchemaExtension(self, path=''):
    result = list()
    url_tool = getToolByName(self, 'portal_url')
    portal = url_tool.getPortalObject()
    obj = None
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            # well, path must habe been wrong
            result.append("No object found for path %s" %path)

    if not obj:
        obj = self
        result.append("Performing actions on self (%s)" %obj.absolute_url())

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" %obj.id)
    sitemanager = obj.getSiteManager()

    sitemanager.registerAdapter(factory=TaggingSchemaExtenderERO,
                                         name=u"osha.metadata.ero")

    result.append("Registered TaggingSchemaExtenderERO as adapter on %s" %obj.id)

    return "\n".join(result)
Пример #3
0
def enableZope3Site(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    if not ISite.providedBy(portal):
        make_objectmanager_site(portal)
        logger.info('Made the portal a Zope3 site.')
    try:
        components = portal.getSiteManager()
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        components = PersistentComponents(name, (next,))
        components.__parent__ = portal
        portal.setSiteManager(components)
        logger.info("Site manager '%s' added." % name)
    else:
        if components.utilities.LookupClass != FiveVerifyingAdapterLookup:
            # for CMF 2.1 beta instances
            components.__parent__ = portal
            components.utilities.LookupClass = FiveVerifyingAdapterLookup
            components.utilities._createLookup()
            components.utilities.__parent__ = components
            logger.info('LookupClass replaced.')
    # Make sure to set the new site as the new active one
    setSite(portal)
    def test_registry_assignment(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.oid = self.portal.invokeFactory('Folder', 'folder')
        setRoles(self.portal, TEST_USER_ID, ['Member'])

        folder = self.portal[self.oid]
        registry = getUtility(IRegistry)

        if not ISite.providedBy(folder):
            make_objectmanager_site(folder)

        setSite(folder)

        pc = getToolByName(folder, 'portal_catalog')
        pc.reindexObject(folder, idxs=['object_provides'])

        enableRegistry(folder)
        self.assertIn(REGISTRY_NAME, folder.objectIds())

        registry = getUtility(IRegistry)
        self.assertTrue(isinstance(registry, LineageRegistry))

        disableRegistry(folder)
        registry = getUtility(IRegistry)
        self.assertTrue(isinstance(registry, Registry))
Пример #5
0
def enableZope3Site(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    if not ISite.providedBy(portal):
        make_objectmanager_site(portal)
        logger.info('Made the portal a Zope3 site.')
    try:
        components = portal.getSiteManager()
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        components = PersistentComponents(name, (next,))
        components.__parent__ = portal
        portal.setSiteManager(components)
        logger.info("Site manager '%s' added." % name)
    else:
        if components.utilities.LookupClass != FiveVerifyingAdapterLookup:
            # for CMF 2.1 beta instances
            components.__parent__ = portal
            components.utilities.LookupClass = FiveVerifyingAdapterLookup
            components.utilities._createLookup()
            components.utilities.__parent__ = components
            logger.info('LookupClass replaced.')
    # Make sure to set the new site as the new active one
    setSite(portal)
def setEROSchemaExtension(self, path=''):
    result = list()
    url_tool = getToolByName(self, 'portal_url')
    portal = url_tool.getPortalObject()
    obj = None
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            # well, path must habe been wrong
            result.append("No object found for path %s" % path)

    if not obj:
        obj = self
        result.append("Performing actions on self (%s)" % obj.absolute_url())

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" % obj.id)
    sitemanager = obj.getSiteManager()

    sitemanager.registerAdapter(factory=TaggingSchemaExtenderERO,
                                name=u"osha.metadata.ero")

    result.append("Registered TaggingSchemaExtenderERO as adapter on %s" %
                  obj.id)

    return "\n".join(result)
Пример #7
0
def enableFolder(folder):
    zope.event.notify(ChildSiteWillBeCreatedEvent(folder))
    if not ISite.providedBy(folder):
        make_objectmanager_site(folder)
    # reindex so that the object_provides index is aware of our
    # new interface
    reindexObjectProvides(folder)
    zope.event.notify(ChildSiteCreatedEvent(folder))
Пример #8
0
 def setUp(cls):
     zinstall_products()
     ZopeTestCase.installProduct('OpenPlans')
     ZopeTestCase.installPackage('borg.localrole')
     make_objectmanager_site(ZopeTestCase.app())
     ZopeTestCase.installProduct('PleiadesGeocoder')
     monkey_stringio()
     txn.commit()
Пример #9
0
def addSiteHandler(site, event):
    """Add a local site manager to a Grok site object upon its creation.

    Grok registers this function so that it gets called each time a
    `grok.Site` instance is added to a container.  It creates a local
    site manager and installs it on the newly created site.

    """
    make_objectmanager_site(site)
Пример #10
0
 def enableSite(self, portal):
     """
     Make the portal a Zope3 site and create a site manager.
     """
     if not ISite.providedBy(portal):
         make_objectmanager_site(portal)
     # The following event is primarily useful for setting the site hooks
     # during test runs.
     notify(SiteManagerCreatedEvent(portal))
Пример #11
0
def addSiteHandler(site, event):
    """Add a local site manager to a Grok site object upon its creation.

    Grok registers this function so that it gets called each time a
    `grok.Site` instance is added to a container.  It creates a local
    site manager and installs it on the newly created site.

    """
    make_objectmanager_site(site)
Пример #12
0
 def setUp(self):
     BaseRegistryTests.setUp(self)
     setHooks()
     self.root.site = Folder(id='site')
     self.site = self.root.site
     make_objectmanager_site(self.site)
     setSite(self.site)
     sm = getSiteManager(self.site)
     sm.registerUtility(ViewletSettingsStorage(), IViewletSettingsStorage)
     self.storage = getUtility(IViewletSettingsStorage)
    def setUp(self):
        from Products.CMFCore.interfaces import IMembershipTool

        TransactionalTest.setUp(self)
        self.site = DummySite('site').__of__(self.app)
        make_objectmanager_site(self.site)
        setSite(self.site)
        self.site._setObject('portal_membership', self._makeOne())
        sm = getSiteManager()
        sm.registerUtility(self.site.portal_membership, IMembershipTool)
Пример #14
0
    def setUp(self):
        from Products.CMFCore.interfaces import IMembershipTool

        TransactionalTest.setUp(self)
        self.site = DummySite('site').__of__(self.app)
        make_objectmanager_site(self.site)
        setSite(self.site)
        self.site._setObject('portal_membership', self._makeOne())
        sm = getSiteManager()
        sm.registerUtility(self.site.portal_membership, IMembershipTool)
Пример #15
0
    def setUp(self):
        setHooks()
        self.site = Folder('site')
        make_objectmanager_site(self.site)
        setSite(self.site)
        sm = getSiteManager()
        self.site.portal_control_panel = PloneControlPanel()
        sm.registerUtility(self.site.portal_control_panel, IControlPanel)

        self._obj = self.site.portal_control_panel
        self._BODY = _CONTROLPANEL_XML
Пример #16
0
    def setUp(self):
        provideAdapter(SharingXMLAdapter, name='plone.app.workflow.sharing')

        site = Folder('plone')
        make_objectmanager_site(site)
        setHooks()
        setSite(site)
        sm = getSiteManager()

        self.site = site
        self.sm = sm
def run(self, path="", do_delete=0):
    result = list()
    result.append("setOshaMetadataExtension")
    url_tool = getToolByName(self, "portal_url")
    portal = url_tool.getPortalObject()
    obj = self
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            result.append("No object found for path %s" % path)
            return "\n".join(result)

    if do_delete and ISite.providedBy(obj):
        noLongerProvides(obj, ISite)
        del obj._components
        result.append("Deleted existing site manager")
        return "\n".join(result)

    # very special and dirty hack
    # We need to kill the existing SiteManager in the European Riskobservatory
    # folder, since it contains a reference to the no longer existing
    # IEroExtender
    if obj.id in ["riskobservatory"] and ISite.providedBy(obj):
        noLongerProvides(obj, ISite)
        del obj._components
        result.append("Deleted existing site manager")

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" % obj.id)

    sitemanager = obj.getSiteManager()
    sitemanager.registerAdapter(OshaMetadataExtender, (IATEvent,), IOrderableSchemaExtender, name="event-oshametadata")

    sitemanager.registerAdapter(
        OshaMetadataExtender, (IATNewsItem,), IOrderableSchemaExtender, name="news-oshametadata"
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender, (IATDocument,), IOrderableSchemaExtender, name="document-oshametadata"
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender, (Iwhoswho,), IOrderableSchemaExtender, name="document-oshametadata"
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender, (IPressRelease,), IOrderableSchemaExtender, name="pressrelease-oshametadata"
    )

    result.append("Registered OshaMetadataExtender as adapter on %s" % obj.id)

    return "\n".join(result)
Пример #18
0
def _extend_destaques(portal):
    folder = portal['destaques']
    if not ISite.providedBy(folder):
        make_objectmanager_site(folder)
    sm = folder.getSiteManager()
    sm.registerAdapter(
        DestaquesExtender,
        (IATNewsItem,),
        ISchemaModifier,
        name=u'DestaqueExtended'
    )
Пример #19
0
    def setUp(self):
        setHooks()
        self.site = Folder('site')
        make_objectmanager_site(self.site)
        setSite(self.site)
        sm = getSiteManager()
        sm.registerUtility(ViewletSettingsStorage(), IViewletSettingsStorage)

        self._obj = getUtility(IViewletSettingsStorage)

        self._BODY = _VIEWLETS_XML
Пример #20
0
    def setUp(self):
        setHooks()
        self.site = Folder('site')
        make_objectmanager_site(self.site)
        setSite(self.site)
        sm = getSiteManager()
        self.site.portal_control_panel = PloneControlPanel()
        sm.registerUtility(self.site.portal_control_panel, IControlPanel)

        self._obj = self.site.portal_control_panel
        self._BODY = _CONTROLPANEL_XML
Пример #21
0
    def setUp(self):
        provideAdapter(SharingXMLAdapter, name='plone.app.workflow.sharing')

        site = Folder('plone')
        make_objectmanager_site(site)
        setHooks()
        setSite(site)
        sm = getSiteManager()

        self.site = site
        self.sm = sm
    def setUp(self):
        setHooks()
        self.site = Folder('site')
        make_objectmanager_site(self.site)
        setSite(self.site)
        sm = getSiteManager()
        self.site.portal_types = DummyTypesTool()
        sm.registerUtility(self.site.portal_types, ITypesTool)
        self.site.portal_factory = FactoryTool()

        self._obj = self.site.portal_factory
        self._BODY = _FACTORYTOOL_XML
Пример #23
0
    def setUp(self):
        setHooks()
        self.site = Folder('site')
        make_objectmanager_site(self.site)
        setSite(self.site)
        sm = getSiteManager()
        self.site.portal_types = DummyTypesTool()
        sm.registerUtility(self.site.portal_types, ITypesTool)
        self.site.portal_factory = FactoryTool()

        self._obj = self.site.portal_factory
        self._BODY = _FACTORYTOOL_XML
Пример #24
0
def enable_childsite(context):
    notify(ChildSiteWillBeCreatedEvent(context))

    # enable site
    if not ISite.providedBy(context):
        make_objectmanager_site(context)

    # provide IChildSite
    alsoProvides(context, IChildSite)

    context.reindexObject(idxs=('object_provides'))
    notify(ChildSiteCreatedEvent(context))
def enable_childsite(context):
    notify(ChildSiteWillBeCreatedEvent(context))

    # enable site
    if not ISite.providedBy(context):
        make_objectmanager_site(context)

    # provide IChildSite
    alsoProvides(context, IChildSite)

    context.reindexObject(idxs=('object_provides'))
    notify(ChildSiteCreatedEvent(context))
Пример #26
0
def enableChildRegistry(context, event):
    """
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    # reindex so that the object_provides index is aware of our
    # new interface
    catalog = getToolByName(context, 'portal_catalog')
    catalog.reindexObject(context, idxs=['object_provides'])
    sm = getSiteManager(context=context)
    if REGISTRY_NAME not in context.objectIds():
        context[REGISTRY_NAME] = LocalRegistry(REGISTRY_NAME).__of__(context)
    sm.registerUtility(component=context[REGISTRY_NAME], provided=IRegistry)
    zope.event.notify(LocalRegistryCreatedEvent(context))
def enable_party(context):
    """ Make this container a local site and add all
        the needed tools, if they're not there yet.
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    sm = context.getSiteManager()
    name = get_name_for_site(context)

    add_tools(context)

    lookup = context.get("newsletter_lookup")

    interface.directlyProvides(lookup, ILocalNewsletterLookup)
    sm.registerUtility(lookup, name=name, provided=ILocalNewsletterLookup)
Пример #28
0
def enable_party(context):
    """ Make this container a local site and add all
        the needed tools, if they're not there yet.
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    sm = context.getSiteManager()
    name = get_name_for_site(context)

    add_tools(context)

    lookup = context.get("newsletter_lookup")

    interface.directlyProvides(lookup, ILocalNewsletterLookup)
    sm.registerUtility(lookup, name=name, provided=ILocalNewsletterLookup)
def enableChildRegistry(context, event):
    """
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    # reindex so that the object_provides index is aware of our
    # new interface
    catalog = getToolByName(context, 'portal_catalog')
    catalog.reindexObject(
        context,
        idxs=['object_provides']
    )
    sm = getSiteManager(context=context)
    if REGISTRY_NAME not in context.objectIds():
        context[REGISTRY_NAME] = LocalRegistry(REGISTRY_NAME).__of__(context)
    sm.registerUtility(component=context[REGISTRY_NAME], provided=IRegistry)
    zope.event.notify(LocalRegistryCreatedEvent(context))
Пример #30
0
    def enable(self):
        """Enable a lineage subsite on this context.
        """
        ctx = self.context
        notify(ChildSiteWillBeCreatedEvent(ctx))

        # enable site
        if not ISite.providedBy(ctx):
            make_objectmanager_site(ctx)

        # provide IChildSite
        alsoProvides(ctx, IChildSite)

        ctx.reindexObject(idxs=('object_provides'))
        notify(ChildSiteCreatedEvent(ctx))

        # redirect
        self.request.response.redirect(ctx.absolute_url())
    def test_utility_only_in_local_site(self):
        # A service_customization can be added only in a local site.
        self.assertTrue(ISite.providedBy(self.root))

        factory = self.root.manage_addProduct['Silva']
        factory.manage_addPublication('publication', 'Publication')
        self.publication = self.root.publication

        self.assertFalse(ISite.providedBy(self.publication))
        factory = self.publication.manage_addProduct['silva.core.layout']
        self.assertRaises(BadRequest,
                          factory.manage_addCustomizationService,
                          'service_customization')

        # Now our publication become a local site.
        make_objectmanager_site(self.publication)
        self.assertTrue(ISite.providedBy(self.publication))
        factory = self.publication.manage_addProduct['silva.core.layout']
        factory.manage_addCustomizationService('service_customization')
        self.assertTrue(hasattr(self.publication, 'service_customization'))
Пример #32
0
    def test_migration_preserves_sharing_settings(self):
        portal = self.layer['portal']
        z2.login(portal['acl_users'], 'manager')
        portal.invokeFactory("Child Folder", "cf1")
        cf1 = portal.cf1
        cf1.setTitle("CF 1")
        make_objectmanager_site(cf1)
        pw = portal.portal_workflow
        pw.doActionFor(cf1, "publish")
        self.failUnless(cf1.Title() == "CF 1")
        self.failUnless(pw.getInfoFor(cf1, "review_state") == "published")
        self.failUnless(ISite.providedBy(cf1))

        cf1.manage_setLocalRoles('testuser', ['Contributor'])

        self.run_migration_step()

        cf1 = portal.cf1
        self.assertEquals(
            ('Contributor',), cf1.get_local_roles_for_userid('testuser'))
Пример #33
0
def run(self, path=''):
    result = list()
    url_tool = getToolByName(self, 'portal_url')
    portal = url_tool.getPortalObject()
    obj = self
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            result.append("No object found for path %s" %path)
            return "\n".join(result)

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" %obj.id)

    sitemanager = obj.getSiteManager()
    sitemanager.registerAdapter(
                            LinkListExtender,
                            (IATEvent,),
                            IOrderableSchemaExtender,
                            name='event-linklist',
                            )

    sitemanager.registerAdapter(
                            LinkListExtender,
                            (IRALink,),
                            IOrderableSchemaExtender,
                            name='ralink-linklist',
                            )

    sitemanager.registerAdapter(
                            LinkListExtender,
                            (ICaseStudy,),
                            IOrderableSchemaExtender,
                            name='casestudy-linklist',
                            )

    result.append("Registered LinkListExtender as adapter on %s" %obj.id)

    return "\n".join(result)
Пример #34
0
def run(self, path=''):
    result = list()
    url_tool = getToolByName(self, 'portal_url')
    portal = url_tool.getPortalObject()
    obj = self
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            result.append("No object found for path %s" % path)
            return "\n".join(result)

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" % obj.id)

    sitemanager = obj.getSiteManager()
    sitemanager.registerAdapter(
        LinkListExtender,
        (IATEvent, ),
        IOrderableSchemaExtender,
        name='event-linklist',
    )

    sitemanager.registerAdapter(
        LinkListExtender,
        (IRALink, ),
        IOrderableSchemaExtender,
        name='ralink-linklist',
    )

    sitemanager.registerAdapter(
        LinkListExtender,
        (ICaseStudy, ),
        IOrderableSchemaExtender,
        name='casestudy-linklist',
    )

    result.append("Registered LinkListExtender as adapter on %s" % obj.id)

    return "\n".join(result)
Пример #35
0
 def make_site(self):
     if self.is_site():
         raise ValueError(_(u'Already a local site.'))
     make_objectmanager_site(self.context)
Пример #36
0
 def make_site(self):
     if self.is_site():
         raise ValueError(_('Already a local site.'))
     make_objectmanager_site(self.context)
Пример #37
0
def enable_site(object, event):
    """When a lineage folder is created, turn it into a component site
    """
    folder = event.object
    if not ISite.providedBy(folder):
        make_objectmanager_site(folder)
Пример #38
0
 def makeSite(self):
     make_objectmanager_site(self.context)
     setSite(self.context)
Пример #39
0
 def test_local_site(self):
     dancefloor = ATFolder("dancefloor")
     self.failUnless(not ISite.providedBy(dancefloor))
     make_objectmanager_site(dancefloor)
     self.failUnless(ISite.providedBy(dancefloor))
Пример #40
0
    def test_migration_preserves_portlets(self):
        portal = self.layer['portal']
        z2.login(portal['acl_users'], 'manager')
        portal.invokeFactory("Child Folder", "cf1")
        cf1 = portal.cf1
        cf1.setTitle("CF 1")
        make_objectmanager_site(cf1)
        pw = portal.portal_workflow
        pw.doActionFor(cf1, "publish")
        self.failUnless(cf1.Title() == "CF 1")
        self.failUnless(pw.getInfoFor(cf1, "review_state") == "published")
        self.failUnless(ISite.providedBy(cf1))
        # Child folders in 0.1 seemed to provide ILocalPortletAssignable but
        # not in 0.6
        if not ILocalPortletAssignable.providedBy(cf1):
            zope.interface.alsoProvides(cf1, ILocalPortletAssignable)
            added_portlet_assignable_interace = True
        else:
            added_portlet_assignable_interace = False

        mapping = cf1.restrictedTraverse('++contextportlets++plone.leftcolumn')
        for m in mapping.keys():
            del mapping[m]
        portlet = zope.component.getUtility(IPortletType,
                                            name='plone.portlet.static.Static')
        addview = mapping.restrictedTraverse('+/' + portlet.addview)
        addview.createAndAdd(data={
            'header': u"test title",
            'text': u"test text"})
        self.assertEquals(len(mapping), 1)

        left_col_manager = zope.component.getUtility(
            IPortletManager,
            name='plone.leftcolumn',
            context=cf1)
        assignment_manager = zope.component.getMultiAdapter(
            (cf1, left_col_manager),
            ILocalPortletAssignmentManager)
        assignment_manager.setBlacklistStatus(GROUP_CATEGORY, None)
        assignment_manager.setBlacklistStatus(CONTENT_TYPE_CATEGORY, False)

        if added_portlet_assignable_interace:
            zope.interface.noLongerProvides(cf1, ILocalPortletAssignable)

        self.run_migration_step()

        cf1 = portal.cf1
        mapping = cf1.restrictedTraverse('++contextportlets++plone.leftcolumn')
        self.assertEquals(len(mapping), 1)

        left_col_manager = zope.component.getUtility(
            IPortletManager,
            name='plone.leftcolumn',
            context=cf1)
        assignment_manager = zope.component.getMultiAdapter(
            (cf1, left_col_manager),
            ILocalPortletAssignmentManager)
        self.assertTrue(
            assignment_manager.getBlacklistStatus(CONTEXT_CATEGORY))
        self.assertTrue(
            assignment_manager.getBlacklistStatus(GROUP_CATEGORY) is None)
        self.assertFalse(
            assignment_manager.getBlacklistStatus(CONTENT_TYPE_CATEGORY))
Пример #41
0
def run(self, path='', do_delete=0):
    result = list()
    result.append('setOshaMetadataExtension')
    url_tool = getToolByName(self, 'portal_url')
    portal = url_tool.getPortalObject()
    obj = self
    if path:
        try:
            obj = portal.restrictedTraverse(path)
        except:
            result.append("No object found for path %s" % path)
            return "\n".join(result)

    if do_delete and ISite.providedBy(obj):
        noLongerProvides(obj, ISite)
        del obj._components
        result.append('Deleted existing site manager')
        return "\n".join(result)

    # very special and dirty hack
    # We need to kill the existing SiteManager in the European Riskobservatory
    # folder, since it contains a reference to the no longer existing
    # IEroExtender
    if obj.id in [
            'riskobservatory',
    ] and ISite.providedBy(obj):
        noLongerProvides(obj, ISite)
        del obj._components
        result.append('Deleted existing site manager')

    if not ISite.providedBy(obj):
        make_objectmanager_site(obj)
        result.append("Turned %s into a local site" % obj.id)

    sitemanager = obj.getSiteManager()
    sitemanager.registerAdapter(
        OshaMetadataExtender,
        (IATEvent, ),
        IOrderableSchemaExtender,
        name='event-oshametadata',
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender,
        (IATNewsItem, ),
        IOrderableSchemaExtender,
        name='news-oshametadata',
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender,
        (IATDocument, ),
        IOrderableSchemaExtender,
        name='document-oshametadata',
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender,
        (Iwhoswho, ),
        IOrderableSchemaExtender,
        name='document-oshametadata',
    )

    sitemanager.registerAdapter(
        OshaMetadataExtender,
        (IPressRelease, ),
        IOrderableSchemaExtender,
        name='pressrelease-oshametadata',
    )

    result.append("Registered OshaMetadataExtender as adapter on %s" % obj.id)

    return "\n".join(result)
 def test_local_site(self):
     dancefloor = ATFolder("dancefloor")
     self.failUnless(not ISite.providedBy(dancefloor))
     make_objectmanager_site(dancefloor)
     self.failUnless(ISite.providedBy(dancefloor))
Пример #43
0
def initializeSite(site, sethook=False, **kw):
    make_objectmanager_site(site)
    if sethook:
         setHooks()
    setSite(site)
Пример #44
0
 def makeSite(self):
     make_objectmanager_site(self.context)
     setSite(self.context)
Пример #45
0
def initializeSite(site, sethook=False, **kw):
    make_objectmanager_site(site)
    if sethook:
        setHooks()
    setSite(site)
Пример #46
0
def create_new_sm(context):
    """Create a new SM.
    """
    make_objectmanager_site(context)
    setSite(context)