Skip to content

Commit

Permalink
[fc] Repository: plone.volto
Browse files Browse the repository at this point in the history
Branch: refs/heads/main
Date: 2024-12-11T13:49:18-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.volto@4406282

Remove unnecessary keywords vocab override

Files changed:
A news/157.bugfix
D src/plone/volto/overrides.zcml
D src/plone/volto/vocabularies/__init__.py
D src/plone/volto/vocabularies/configure.zcml
D src/plone/volto/vocabularies/subject.py
Repository: plone.volto

Branch: refs/heads/main
Date: 2024-12-11T15:05:10-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.volto@9b25cc1

Merge pull request #170 from plone/157-no-custom-keyword-vocab

Remove unnecessary keywords vocab override

Files changed:
A news/157.bugfix
D src/plone/volto/overrides.zcml
D src/plone/volto/vocabularies/__init__.py
D src/plone/volto/vocabularies/configure.zcml
D src/plone/volto/vocabularies/subject.py
  • Loading branch information
davisagli committed Dec 11, 2024
1 parent cb22e6a commit 76c73f6
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
Repository: Products.CMFEditions
Repository: plone.volto


Branch: refs/heads/master
Date: 2024-12-11T14:08:16-08:00
Branch: refs/heads/main
Date: 2024-12-11T13:49:18-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/Products.CMFEditions/commit/da3a03ceaafcbc5d7c7a10acaa1c7d104f1eb7ef
Commit: https://github.com/plone/plone.volto/commit/44062829a9f9926b70f63fb3cc22ad0d8c62d63e

Preparing release 4.0.4
Remove unnecessary keywords vocab override

Files changed:
M CHANGES.rst
M setup.py
D news/26.bugfix
A news/157.bugfix
D src/plone/volto/overrides.zcml
D src/plone/volto/vocabularies/__init__.py
D src/plone/volto/vocabularies/configure.zcml
D src/plone/volto/vocabularies/subject.py

b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 20d6e4f2..66f734e5 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -8,6 +8,16 @@ Changelog\n \n .. towncrier release notes start\n \n+4.0.4 (2024-12-11)\n+------------------\n+\n+Bug fixes:\n+\n+\n+- Fix "Can\'t pickle objects in acquisition wrappers." error in\n+ `OMOutsideChildrensModifier` and `OMInsideChildrensModifier`. @davisagli (#26)\n+\n+\n 4.0.3 (2024-01-18)\n ------------------\n \ndiff --git a/news/26.bugfix b/news/26.bugfix\ndeleted file mode 100644\nindex 0a58eb0d..00000000\n--- a/news/26.bugfix\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-Fix "Can\'t pickle objects in acquisition wrappers." error in\n-`OMOutsideChildrensModifier` and `OMInsideChildrensModifier`. @davisagli\ndiff --git a/setup.py b/setup.py\nindex 3ffbd319..42ad53e6 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -3,7 +3,7 @@\n from setuptools import setup\n \n \n-version = "4.0.4.dev0"\n+version = "4.0.4"\n \n long_description = (\n f"{Path(\'README.rst\').read_text()}\\n{Path(\'CHANGES.rst\').read_text()}"\n'
b'diff --git a/news/157.bugfix b/news/157.bugfix\nnew file mode 100644\nindex 00000000..ec311370\n--- /dev/null\n+++ b/news/157.bugfix\n@@ -0,0 +1 @@\n+Remove override of Plone\'s `plone.app.vocabularies.Keywords` vocabulary. @davisagli\ndiff --git a/src/plone/volto/overrides.zcml b/src/plone/volto/overrides.zcml\ndeleted file mode 100644\nindex 00b3440b..00000000\n--- a/src/plone/volto/overrides.zcml\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-<configure xmlns="http://namespaces.zope.org/zope">\n-\n- <utility\n- name="plone.app.vocabularies.Keywords"\n- component=".vocabularies.subject.KeywordsVocabularyFactory"\n- />\n-\n-</configure>\ndiff --git a/src/plone/volto/vocabularies/__init__.py b/src/plone/volto/vocabularies/__init__.py\ndeleted file mode 100644\nindex e69de29b..00000000\ndiff --git a/src/plone/volto/vocabularies/configure.zcml b/src/plone/volto/vocabularies/configure.zcml\ndeleted file mode 100644\nindex 71af777b..00000000\n--- a/src/plone/volto/vocabularies/configure.zcml\n+++ /dev/null\n@@ -1,6 +0,0 @@\n-<configure\n- xmlns="http://namespaces.zope.org/zope"\n- i18n_domain="plone.volto"\n- >\n-\n-</configure>\ndiff --git a/src/plone/volto/vocabularies/subject.py b/src/plone/volto/vocabularies/subject.py\ndeleted file mode 100644\nindex 3bfcfe38..00000000\n--- a/src/plone/volto/vocabularies/subject.py\n+++ /dev/null\n@@ -1,110 +0,0 @@\n-from BTrees.IIBTree import intersection\n-from plone.app.layout.navigation.root import getNavigationRootObject\n-from plone.app.vocabularies.terms import safe_encode\n-from plone.registry.interfaces import IRegistry\n-from Products.CMFCore.utils import getToolByName\n-from zope.component import queryUtility\n-from zope.component.hooks import getSite\n-from zope.interface import directlyProvides\n-from zope.interface import implementer\n-from zope.schema.interfaces import ITitledTokenizedTerm\n-from zope.schema.interfaces import ITokenizedTerm\n-from zope.schema.interfaces import IVocabularyFactory\n-from zope.schema.vocabulary import SimpleVocabulary\n-\n-\n-@implementer(ITokenizedTerm)\n-class UnsafeSimpleSubjectTerm:\n- """Simple tokenized term that allows unicode in the token"""\n-\n- def __init__(self, value, token, title):\n- """Create a term for value and token. If token is omitted,\n- str(value) is used for the token. If title is provided,\n- term implements ITitledTokenizedTerm.\n- """\n- self.value = value\n- self.token = token\n- self.title = title\n- if title is not None:\n- directlyProvides(self, ITitledTokenizedTerm)\n-\n-\n-# Override the keywords vocabulary with an unsafe version. plone.restapi\n-# currently store the raw token for the subject field. Override the vocabulary\n-# with a version that uses the Keyword as a token and does not encode it.\n-# Mostly copied from plone.app.vocabularies.catalog.\n-# See https://github.com/plone/plone.restapi/issues/782\n-\n-\n-def unsafe_simplevocabulary_from_values(values, query=None):\n- return SimpleVocabulary(\n- [\n- UnsafeSimpleSubjectTerm(value, value, value)\n- for value in values\n- if query is None or safe_encode(query) in safe_encode(value)\n- ]\n- )\n-\n-\n-safe_simplevocabulary_from_values = unsafe_simplevocabulary_from_values\n-\n-\n-@implementer(IVocabularyFactory)\n-class KeywordsVocabulary:\n- """Override Keywords vocabulary to provide the real Keyword as the token."""\n-\n- # Allow users to customize the index to easily create\n- # KeywordVocabularies for other keyword indexes\n- keyword_index = "Subject"\n- path_index = "path"\n-\n- def section(self, context):\n- """gets section from which subjects are used."""\n- registry = queryUtility(IRegistry)\n- if registry is None:\n- return None\n- if registry.get("plone.subjects_of_navigation_root", False):\n- portal = getToolByName(context, "portal_url").getPortalObject()\n- return getNavigationRootObject(context, portal)\n- return None\n-\n- def all_keywords(self, kwfilter):\n- site = getSite()\n- self.catalog = getToolByName(site, "portal_catalog", None)\n- if self.catalog is None:\n- return SimpleVocabulary([])\n- index = self.catalog._catalog.getIndex(self.keyword_index)\n- return safe_simplevocabulary_from_values(index._index, query=kwfilter)\n-\n- def keywords_of_section(self, section, kwfilter):\n- """Valid keywords under the given section."""\n- pcat = getToolByName(section, "portal_catalog")\n- cat = pcat._catalog\n- path_idx = cat.indexes[self.path_index]\n- tags_idx = cat.indexes[self.keyword_index]\n- result = []\n- # query all oids of path - low level\n- pquery = {\n- self.path_index: {"query": "/".join(section.getPhysicalPath()), "depth": -1}\n- }\n- kwfilter = safe_encode(kwfilter)\n- # uses internal zcatalog specific details to quickly get the values.\n- path_result, info = path_idx._apply_index(pquery)\n- for tag in tags_idx.uniqueValues():\n- if kwfilter and kwfilter not in safe_encode(tag):\n- continue\n- tquery = {self.keyword_index: tag}\n- tags_result, info = tags_idx._apply_index(tquery)\n- if intersection(path_result, tags_result):\n- result.append(tag)\n- # result should be sorted, because uniqueValues are.\n- return safe_simplevocabulary_from_values(result)\n-\n- def __call__(self, context, query=None):\n- section = self.section(context)\n- if section is None:\n- return self.all_keywords(query)\n- return self.keywords_of_section(section, query)\n-\n-\n-KeywordsVocabularyFactory = KeywordsVocabulary()\n'

Repository: Products.CMFEditions
Repository: plone.volto


Branch: refs/heads/master
Date: 2024-12-11T14:09:30-08:00
Branch: refs/heads/main
Date: 2024-12-11T15:05:10-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/Products.CMFEditions/commit/a56c1d89019faaf75023bf008bac5d6de1e36eb9
Commit: https://github.com/plone/plone.volto/commit/9b25cc19e721a9badce28142aeeaf7cdd4f00e99

back to dev
Merge pull request #170 from plone/157-no-custom-keyword-vocab

Remove unnecessary keywords vocab override

Files changed:
M setup.py
A news/157.bugfix
D src/plone/volto/overrides.zcml
D src/plone/volto/vocabularies/__init__.py
D src/plone/volto/vocabularies/configure.zcml
D src/plone/volto/vocabularies/subject.py

b'diff --git a/setup.py b/setup.py\nindex 42ad53e..e000140 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -3,7 +3,7 @@\n from setuptools import setup\n \n \n-version = "4.0.4"\n+version = "4.0.5.dev0"\n \n long_description = (\n f"{Path(\'README.rst\').read_text()}\\n{Path(\'CHANGES.rst\').read_text()}"\n'
b'diff --git a/news/157.bugfix b/news/157.bugfix\nnew file mode 100644\nindex 00000000..ec311370\n--- /dev/null\n+++ b/news/157.bugfix\n@@ -0,0 +1 @@\n+Remove override of Plone\'s `plone.app.vocabularies.Keywords` vocabulary. @davisagli\ndiff --git a/src/plone/volto/overrides.zcml b/src/plone/volto/overrides.zcml\ndeleted file mode 100644\nindex 00b3440b..00000000\n--- a/src/plone/volto/overrides.zcml\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-<configure xmlns="http://namespaces.zope.org/zope">\n-\n- <utility\n- name="plone.app.vocabularies.Keywords"\n- component=".vocabularies.subject.KeywordsVocabularyFactory"\n- />\n-\n-</configure>\ndiff --git a/src/plone/volto/vocabularies/__init__.py b/src/plone/volto/vocabularies/__init__.py\ndeleted file mode 100644\nindex e69de29b..00000000\ndiff --git a/src/plone/volto/vocabularies/configure.zcml b/src/plone/volto/vocabularies/configure.zcml\ndeleted file mode 100644\nindex 71af777b..00000000\n--- a/src/plone/volto/vocabularies/configure.zcml\n+++ /dev/null\n@@ -1,6 +0,0 @@\n-<configure\n- xmlns="http://namespaces.zope.org/zope"\n- i18n_domain="plone.volto"\n- >\n-\n-</configure>\ndiff --git a/src/plone/volto/vocabularies/subject.py b/src/plone/volto/vocabularies/subject.py\ndeleted file mode 100644\nindex 3bfcfe38..00000000\n--- a/src/plone/volto/vocabularies/subject.py\n+++ /dev/null\n@@ -1,110 +0,0 @@\n-from BTrees.IIBTree import intersection\n-from plone.app.layout.navigation.root import getNavigationRootObject\n-from plone.app.vocabularies.terms import safe_encode\n-from plone.registry.interfaces import IRegistry\n-from Products.CMFCore.utils import getToolByName\n-from zope.component import queryUtility\n-from zope.component.hooks import getSite\n-from zope.interface import directlyProvides\n-from zope.interface import implementer\n-from zope.schema.interfaces import ITitledTokenizedTerm\n-from zope.schema.interfaces import ITokenizedTerm\n-from zope.schema.interfaces import IVocabularyFactory\n-from zope.schema.vocabulary import SimpleVocabulary\n-\n-\n-@implementer(ITokenizedTerm)\n-class UnsafeSimpleSubjectTerm:\n- """Simple tokenized term that allows unicode in the token"""\n-\n- def __init__(self, value, token, title):\n- """Create a term for value and token. If token is omitted,\n- str(value) is used for the token. If title is provided,\n- term implements ITitledTokenizedTerm.\n- """\n- self.value = value\n- self.token = token\n- self.title = title\n- if title is not None:\n- directlyProvides(self, ITitledTokenizedTerm)\n-\n-\n-# Override the keywords vocabulary with an unsafe version. plone.restapi\n-# currently store the raw token for the subject field. Override the vocabulary\n-# with a version that uses the Keyword as a token and does not encode it.\n-# Mostly copied from plone.app.vocabularies.catalog.\n-# See https://github.com/plone/plone.restapi/issues/782\n-\n-\n-def unsafe_simplevocabulary_from_values(values, query=None):\n- return SimpleVocabulary(\n- [\n- UnsafeSimpleSubjectTerm(value, value, value)\n- for value in values\n- if query is None or safe_encode(query) in safe_encode(value)\n- ]\n- )\n-\n-\n-safe_simplevocabulary_from_values = unsafe_simplevocabulary_from_values\n-\n-\n-@implementer(IVocabularyFactory)\n-class KeywordsVocabulary:\n- """Override Keywords vocabulary to provide the real Keyword as the token."""\n-\n- # Allow users to customize the index to easily create\n- # KeywordVocabularies for other keyword indexes\n- keyword_index = "Subject"\n- path_index = "path"\n-\n- def section(self, context):\n- """gets section from which subjects are used."""\n- registry = queryUtility(IRegistry)\n- if registry is None:\n- return None\n- if registry.get("plone.subjects_of_navigation_root", False):\n- portal = getToolByName(context, "portal_url").getPortalObject()\n- return getNavigationRootObject(context, portal)\n- return None\n-\n- def all_keywords(self, kwfilter):\n- site = getSite()\n- self.catalog = getToolByName(site, "portal_catalog", None)\n- if self.catalog is None:\n- return SimpleVocabulary([])\n- index = self.catalog._catalog.getIndex(self.keyword_index)\n- return safe_simplevocabulary_from_values(index._index, query=kwfilter)\n-\n- def keywords_of_section(self, section, kwfilter):\n- """Valid keywords under the given section."""\n- pcat = getToolByName(section, "portal_catalog")\n- cat = pcat._catalog\n- path_idx = cat.indexes[self.path_index]\n- tags_idx = cat.indexes[self.keyword_index]\n- result = []\n- # query all oids of path - low level\n- pquery = {\n- self.path_index: {"query": "/".join(section.getPhysicalPath()), "depth": -1}\n- }\n- kwfilter = safe_encode(kwfilter)\n- # uses internal zcatalog specific details to quickly get the values.\n- path_result, info = path_idx._apply_index(pquery)\n- for tag in tags_idx.uniqueValues():\n- if kwfilter and kwfilter not in safe_encode(tag):\n- continue\n- tquery = {self.keyword_index: tag}\n- tags_result, info = tags_idx._apply_index(tquery)\n- if intersection(path_result, tags_result):\n- result.append(tag)\n- # result should be sorted, because uniqueValues are.\n- return safe_simplevocabulary_from_values(result)\n-\n- def __call__(self, context, query=None):\n- section = self.section(context)\n- if section is None:\n- return self.all_keywords(query)\n- return self.keywords_of_section(section, query)\n-\n-\n-KeywordsVocabularyFactory = KeywordsVocabulary()\n'

0 comments on commit 76c73f6

Please sign in to comment.