-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new upgrade step is also provided to update the objects_provides catalog index.
- Loading branch information
Showing
10 changed files
with
183 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<metadata> | ||
<version>3045</version> | ||
<version>3046</version> | ||
</metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding:utf-8 -*- | ||
from plone import api | ||
from sc.social.like.logger import logger | ||
from sc.social.like.utils import get_valid_objects | ||
|
||
import transaction | ||
|
||
|
||
def reindex_catalog(setup_tool): | ||
"""Reindex objects to fix interfaces on the catalog.""" | ||
test = 'test' in setup_tool.REQUEST # used to ignore transactions on tests | ||
logger.info( | ||
u'Reindexing the catalog. ' | ||
u'This process could take a long time on large sites. Be patient.' | ||
) | ||
catalog = api.portal.get_tool('portal_catalog') | ||
results = catalog() | ||
logger.info(u'Found {0} objects'.format(len(results))) | ||
n = 0 | ||
for obj in get_valid_objects(results): | ||
catalog.catalog_object(obj, idxs=['object_provides'], update_metadata=False) | ||
n += 1 | ||
if n % 1000 == 0 and not test: | ||
transaction.commit() | ||
logger.info('{0} items processed.'.format(n)) | ||
|
||
if not test: | ||
transaction.commit() | ||
logger.info('Done.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"> | ||
|
||
<genericsetup:upgradeSteps | ||
source="3045" | ||
destination="3046" | ||
profile="sc.social.like:default"> | ||
|
||
<genericsetup:upgradeStep | ||
title="Reindex catalog" | ||
description="Reindex objects to fix interfaces on the catalog." | ||
handler=".reindex_catalog" | ||
/> | ||
|
||
</genericsetup:upgradeSteps> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters