示例#1
0
def reindex_membrane_tool(context):
    """
    Triggers a reindex of the membrane_tool catalog.
    """
    mbtool = getToolByName(context, 'membrane_tool')
    mbtool.refreshCatalog()
    logger.info('Membrane tool reindexed')
示例#2
0
def add_sortable_title_membranetool_index(setup_tool):
    profile_id = setup_tool.REQUEST.form.get('profile_id')
    result = run_import_step(setup_tool, 'membranetool', profile_id=profile_id)
    logger.info('Reimported membrane tool from GS profile:\n%r' % result)
    
    getToolByName(setup_tool, 'membrane_tool').refreshCatalog()
    logger.info('Reindexed membrane_tool ZCatalog')
示例#3
0
def add_mailing_list_subscribers_index(setup_tool):
    profile_id = setup_tool.REQUEST.form.get('profile_id')
    result = run_import_step(setup_tool, 'catalog', profile_id=profile_id)
    logger.info('Reimported portal_catalog from GS profile:\n%r' % result)
    
    getToolByName(setup_tool, 'portal_catalog').refreshCatalog()
    logger.info('Reindexed portal_catalog ZCatalog')
示例#4
0
def fixup_list_lookup_utility(context):
    """
    Makes sure listen's IListLookup utility is installed at the portal
    level.
    """
    result = run_import_step(context, 'componentregistry',
                             profile_id='Products.listen:listen',
                             )
    logger.info(result)
示例#5
0
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')
示例#6
0
def mark_listen_folders(context):
    """
    Marks all 'lists' folders w/ the IListenContainer interface.
    """
    cat = getToolByName(context, 'portal_catalog')
    projs = cat.unrestrictedSearchResults(portal_type='OpenProject')
    for proj_brain in projs:
        proj = proj_brain.getObject()
        listfolder = proj._getOb('lists', None)
        if (listfolder is not None and
            not IListenContainer.providedBy(listfolder)):
            alsoProvides(listfolder, IListenContainer)
            logger.info('Marked folder with IListenContainer: %s'
                        % '/'.join(listfolder.getPhysicalPath()))
示例#7
0
def mark_memsynced_mailing_lists(context):
    """
     http://www.openplans.org/projects/opencore/lists/opencore-dev/archive/2009/04/1239543233615/forum_view
    """
    cat = getToolByName(context, 'portal_catalog')
    lists = cat.unrestrictedSearchResults(portal_type='Open Mailing List')
    i = 0; changed = False
    for list in lists:
        print list.getId
        i += 1
        if list.getId.endswith('-discussion'):
            list = list.getObject()
            proj = list.aq_inner.aq_parent.aq_parent
            if not list.getId().startswith(proj.getId()):
                # apparently not 'fooproject-discussion'
                continue
            alsoProvides(list, ISyncWithProjectMembership)
            logger.info("marked list %s with ISyncWithProjectMembership" % list.getId)
            changed = True

        if changed and i % 400 == 0:
            transaction.commit()
            logger.info('===== COMMITTING (%d of %d) ====' %(i, len(lists)))
            changed = False

    transaction.commit()
    logger.info('==== COMMITTING (%d of %d) ====' %(i, len(lists)))
示例#8
0
def retitle_member_areas(context):
    """
    change the title of the member areas on the site to use
    member id instead of member title, copied from `to_0_15_0` per
    http://www.openplans.org/projects/opencore/lists/opencore-dev/archive/2009/03/1236185295052

    Because the member folder's Title should not be exposed anywhere in the
    standard UI, this particular upgrade is non-critical; however, just to
    be on the safe side, you'll probably want to run it.

    The differences between this function and the 0.15 upgrade function it was
    cargoculted from are as follows:
     * It reverses that function for member folders. That is, in the 0.15 upgrade member folders
       were retitled to match their members' Title. Now we are reverting that and setting the
       title to match the member's id.
     * It does not touch member wiki home pages' Titles. Since that property can be changed
       through the UI by the member who owns the page, there's no reason to do it here.
    """

    portal = getToolByName(context, 'portal_url').getPortalObject()
    mdtool = getToolByName(portal, 'portal_memberdata')
    mem_ids = dict.fromkeys(
        mdtool.objectIds(spec='OpenMember'))

    i = 0
    changed = False
    for mem_id, home in portal.people.objectItems():
        if mem_id not in mem_ids:
            # what would this mean?
            continue
        i += 1
        member = mdtool._getOb(mem_id)
        mem_title = member.Title() or mem_id

        if home.Title() != mem_id:
            # This is not (or at least should not be) used anywhere in the standard UI, per #2779
            # It's not directly user-controllable, so we always do the upgrade
            changed = True
            home.setTitle(mem_id)
            home.reindexObject(idxs=['Title'])
            logger.info('retitled folder for %s' % mem_id)

        if changed and i % 400 == 0:
            transaction.commit()
            logger.info('===== COMMITTING (%d of %d) ====' %(i, len(mem_ids)))
            changed = False

    transaction.commit()
    logger.info('==== COMMITTING (%d of %d) ====' %(i, len(mem_ids)))
示例#9
0
def retitle_member_areas(context):
    """change the title of the member areas on the site to use
    member title instead of member id"""
    # forward-ported from the people-cloud branch.
    portal = getToolByName(context, 'portal_url').getPortalObject()
    mdtool = getToolByName(portal, 'portal_memberdata')
    mem_ids = dict.fromkeys(
        mdtool.objectIds(spec='OpenMember'))
    i = 0
    changed = False
    for mem_id, home in portal.people.objectItems():
        if mem_id not in mem_ids:
            continue
        i += 1
        member = mdtool._getOb(mem_id)
        mem_title = member.Title() or mem_id
        if home.Title() != mem_title:
            # This is used in top nav.
            # It's not directly user-controllable, so we always do the upgrade
            changed = True
            home.setTitle(mem_title)
            home.reindexObject(idxs=['Title'])
            logger.info('retitled folder for %s' % mem_id)
        page = home._getOb('%s-home' % mem_id, None)
        if page is not None and page.Title() == '%s Home' % mem_id and mem_id != mem_title:
            # Pages are user-renamable so we had to check for a nonstandard title
            changed = True
            page.setTitle('%s Home' % mem_title)
            page.reindexObject(idxs=['Title'])
            logger.info('retitled home page for %s' % mem_id)
        if changed and i % 400 == 0:
            transaction.commit()
            logger.info('===== COMMITTING (%d of %d) ====' %(i, len(mem_ids)))
            changed = False
    transaction.commit()
    logger.info('==== COMMITTING (%d of %d) ====' %(i, len(mem_ids)))
示例#10
0
def update_rolemap(context):
    result = run_import_step(context, 'rolemap')
    logger.info(result)
示例#11
0
def reapply_workflow_profile(context):
    result = run_import_step(context, 'workflow')
    logger.info(result)
示例#12
0
def reapply_type_information(context):
    result = run_import_step(context, 'typeinfo')
    logger.info(result)
示例#13
0
def declare_supported_languages(setup_tool):
    profile_id = setup_tool.REQUEST.form.get('profile_id')
    result = run_import_step(setup_tool, 'languagetool', profile_id=profile_id)
    logger.info('Reimported portal_languages tool from GS profile:\n%s' % result)
示例#14
0
def bootstrap_member_deletion_queue(setup_tool):
    profile_id = setup_tool.REQUEST.form.get('profile_id')
    result = run_import_step(setup_tool, 'addMemberCleanupQueue', profile_id=profile_id)
    logger.info(result)
示例#15
0
def fix_member_indexes(context, commit_batchsize=200):
    logger.info("Fixing membrane project_ids index")
    portal = getToolByName(context, 'portal_url').getPortalObject()
    mship_tool = getToolByName(portal, 'portal_membership')
    membrane_tool = getToolByName(portal, 'membrane_tool')
    fixed = 0
    brains = membrane_tool.unrestrictedSearchResults()
    total_count = len(brains)
    for i, brain in enumerate(brains):
        i += 1
        msg = "(%d out of %d)" % (i, total_count)
        try:
            mem = mship_tool.getMemberById(brain.getId)
        except AssertionError:
            # This should be fixed in membrane r73080.
            logger.error('%s: Assertion error trying to find user %r, you probably need to update membrane?' % (msg, brain.getId))
            continue
        if mem is None:
            logger.info("%s Got no member for id %r, should not happen" % (msg, brain.getId))
        elif set(mem.project_ids()) != set(brain.project_ids):
            # Don't want to reindex if I don't have to... our db is
            # bloated enough.
            subscribers.reindex_member_project_ids(mem, None)
            fixed += 1
            logger.info("%s *** FIXED %r" % (msg, brain.getId))
        else:
            logger.info("%s already ok: %r" % (msg, brain.getId))
        if fixed and (i % commit_batchsize == 0):
            transaction.get().note("reindexing members project_ids")
            transaction.commit()
            logger.info( "======= COMMITING =======================")
    
    logger.info( "Fixed %d out of %d total." % (fixed, total_count))
    if fixed:
        transaction.commit()
    else:
        transaction.abort()
        logger.info("Nothing to commit.")