コード例 #1
0
def clean_old_five_sm(context, create=True):
    """Disable the old Five sucky SM.
    """
    from Products.Five.site.localsite import disableLocalSiteHook
    disableLocalSiteHook(context)
    if not create:
        return None
    create_new_sm(context)
    return context.getSiteManager()
コード例 #2
0
ファイル: to_0_13_0.py プロジェクト: socialplanning/opencore
def migrate_mlist_component_registries(context):
    """
    Upgrades all of the mailing lists' local component registries to
    the Five 1.5 format.
    """
    site = getToolByName(context, 'portal_url').getPortalObject()
    cat = getToolByName(context, 'portal_catalog')
    list_brains = cat.unrestrictedSearchResults(
        portal_type='Open Mailing List', sort_on='id')
    from AccessControl import getSecurityManager
    logger.debug("Running as %s" %  getSecurityManager().getUser())
    logger.debug("Got %d lists to migrate" % len(list_brains))

    for lbrain in list_brains:
        lst = lbrain.getObject()

        if 'utilities' in lst.objectIds():
            logger.debug(" MIGRATING %r" % lbrain.id)
        else:
            # We already migrated this one.
            logger.debug("    already migrated %r, skipping..." % lbrain.id)
            continue

        utilities = lst.utilities.objectItems()

        disableLocalSiteHook(lst)
        components_view = queryMultiAdapter((lst, lst.REQUEST),
                                            Interface, 'components.html')
        components_view.makeSite()
        setSite(lst)
        lst.manage_delObjects(['utilities'])

        site_manager = getSiteManager()
        for id, utility in utilities:
            info = id.split('-')
            if len(info) == 1:
                name = ''
            else:
                name = info[1]
            interface_name = info[0]

            for iface in providedBy(utility):
                if iface.getName() == interface_name:
                    site_manager.registerUtility(aq_base(utility),
                                                 iface, name=name)
            if interface_name == 'ISearchableArchive':
                lst._setObject('ISearchableArchive', aq_base(utility))

        logger.info('%s mailing list component registry migrated'
                    % lst.getId())

    logger.info('Mailing list local component registry migration complete')
コード例 #3
0
ファイル: browser.py プロジェクト: bendavis78/zope
    def unmakeSite(self):
        """Convert a site to a possible site"""
        if not self.isSite():
            raise ValueError('This is not a site')

        disableLocalSiteHook(self.context)

        # disableLocalSiteHook circumcised our context so that it's
        # not an ISite anymore.  That can mean that certain things for
        # it can't be found anymore.  So, for the rest of this request
        # (which will be over in about 20 CPU cycles), already clear
        # the local site from the thread local.
        clearSite()

        return "This object is no longer a site"