Skip to content

Commit

Permalink
Don't let the lineage.childsites vocabulary fail, if there are multip…
Browse files Browse the repository at this point in the history
…le childsites with the same id.
  • Loading branch information
thet committed Aug 28, 2014
1 parent 4e4cec4 commit c091f96
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.5 (unreleased)
----------------

- Don't let the ``lineage.childsites`` vocabulary fail, if there are multiple
childsites with the same id.
[thet]


0.4 (2012-01-10)
----------------

Expand Down
17 changes: 13 additions & 4 deletions lineage/index/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ def childSiteVocabulary(context):
"""
cat = getToolByName(context, 'portal_catalog')

brains = cat(object_provides=IChildSite.__identifier__,
sort_on='sortable_title')
terms = [SimpleTerm(value=brain.id, token=brain.id, title=brain.Title)
for brain in brains]
brains = cat(
object_provides=IChildSite.__identifier__,
sort_on='sortable_title'
)

set_brains = []
terms = []
for brain in brains:
val = brain.id
if val not in set_brains:
# vocabulary values and tokens must be unique
set_brains.append(val)
terms.append(SimpleTerm(value=val, token=val, title=brain.Title))
return SimpleVocabulary(terms)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '0.4'
version = '0.5.dev0'

setup(name='lineage.index',
version=version,
Expand Down

2 comments on commit c091f96

@frisi
Copy link
Member

@frisi frisi commented on c091f96 Nov 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

childsites with the same id can only occure in setups where childsites are located in different subfolders of the main portal. eg:

plone/folder1/subsite1 (Title "Super Subsite")
plone/folder2/subsite1 (Title "Best Subsite")

this "fix" basically makes content from both sides be labeled with "Super Subsite", even if it's from folder2/subsite1.

a real fix for this problem would be to change the way the index is computed to use the portal-relative-path instead of the plain id.
this would require an upgrade step to update existing catalog data, too.

i'd prefer to go for the real fix, although i currently have no resources to implement it.

if we do a release containing this workaround, i'd at least log an error message ("lineage.index does not support subsites with the same id - see ticket xxx") when a brain gets skipped while building the vocabulary. the version number would be 0.4.1 rather than 0.5

@thet
Copy link
Member Author

@thet thet commented on c091f96 Nov 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree. currently the vocab is only used for the subsite switcher viewlet.
but however, i won't make a release yet and postpone the real fix until time has come.

Please sign in to comment.