Skip to content

Commit

Permalink
work around index queue to not have duplicate uncatalog
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jul 12, 2019
1 parent 9d2e783 commit 5192202
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plone-5.2.x.cfg
@@ -1,4 +1,4 @@
[buildout]
extends =
https://dist.plone.org/release/5.2-latest/versions.cfg
https://dist.plone.org/release/5.2-pending/versions.cfg
base.cfg
2 changes: 1 addition & 1 deletion requirements-5.2.x.txt
@@ -1 +1 @@
-r https://dist.plone.org/release/5.2-latest/requirements.txt
-r https://dist.plone.org/release/5.2-pending/requirements.txt
13 changes: 9 additions & 4 deletions src/plone/app/multilingualindexes/languagefallback.py
Expand Up @@ -257,14 +257,17 @@ def fallback_finder(context, row):
def reindex_languagefallback(event):
"""Object event subscriber to reindex the index 'language_or_fallback'.
"""
catalog = api.portal.get_tool("portal_catalog")
if "language_or_fallback" not in catalog.indexes():
return
if ITranslationRegisteredEvent.providedBy(event):
other = event.target
else:
other = event.old_object
annotate_documentid_to_tg(event.object)
annotate_documentid_to_tg(other)
event.object.reindexObject(idxs=["language_or_fallback"])
other.reindexObject(idxs=["language_or_fallback"])
# annotate_documentid_to_tg(event.object)
# annotate_documentid_to_tg(other)
catalog.catalog_object(event.object, idxs=["language_or_fallback"])
catalog.catalog_object(other, idxs=["language_or_fallback"])


def annotate_documentid_to_tg(obj):
Expand All @@ -276,6 +279,8 @@ def annotate_documentid_to_tg(obj):
if not tg:
return
catalog = api.portal.get_tool("portal_catalog")
if "language_or_fallback" not in catalog.indexes():
return
rid = catalog.getrid("/".join(obj.getPhysicalPath()))
request = getRequest()
annotation = getattr(request, _REQ_ANNOTAION, None)
Expand Down

0 comments on commit 5192202

Please sign in to comment.