-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fc] Repository: plone.app.dexterity
Branch: refs/heads/master Date: 2022-05-09T15:32:39+02:00 Author: Peter Holzer (agitator) <peter.holzer@agitator.com> Commit: plone/plone.app.dexterity@9ff07c6 Don't acquire .language from portal root. Files changed: M plone/app/dexterity/behaviors/metadata.py Repository: plone.app.dexterity Branch: refs/heads/master Date: 2022-05-09T15:36:08+02:00 Author: Peter Holzer (agitator) <peter.holzer@agitator.com> Commit: plone/plone.app.dexterity@3e57847 add news Files changed: A news/350.bugfix Repository: plone.app.dexterity Branch: refs/heads/master Date: 2022-05-09T18:37:12+02:00 Author: Peter Holzer (agitator) <peter.holzer@agitator.com> Commit: plone/plone.app.dexterity@e0cd920 use getattr Files changed: M plone/app/dexterity/behaviors/metadata.py Repository: plone.app.dexterity Branch: refs/heads/master Date: 2022-05-09T21:42:12+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.app.dexterity@692d932 Merge pull request #350 from plone/defaultlanglookup [6.0] Don't acquire .language from portal root. Files changed: A news/350.bugfix M plone/app/dexterity/behaviors/metadata.py
- Loading branch information
1 parent
e8f620f
commit 157ba50
Showing
1 changed file
with
45 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,63 @@ | ||
Repository: plone.restapi | ||
Repository: plone.app.dexterity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-05-09T12:35:44+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.restapi/commit/e13d15c78c2d074608b250a1e32bf7c118e283cd | ||
Date: 2022-05-09T15:32:39+02:00 | ||
Author: Peter Holzer (agitator) <peter.holzer@agitator.com> | ||
Commit: https://github.com/plone/plone.app.dexterity/commit/9ff07c63d45060581b9fc139d7af0690c581d38c | ||
|
||
Don't acquire .language from portal root. | ||
|
||
Move the generation of two test scripts out of buildout. | ||
Files changed: | ||
M plone/app/dexterity/behaviors/metadata.py | ||
|
||
The buildout parts theoretically could automatically replace something in the scripts, but this feature was not used. | ||
So in practice it simply renamed the files and copied them to the bin directory. | ||
Instead, I now rename them in the repository, and call them directly in GHA. | ||
Simplifies things. | ||
b'diff --git a/plone/app/dexterity/behaviors/metadata.py b/plone/app/dexterity/behaviors/metadata.py\nindex 8eabe5b..88555d6 100644\n--- a/plone/app/dexterity/behaviors/metadata.py\n+++ b/plone/app/dexterity/behaviors/metadata.py\n@@ -38,22 +38,27 @@ def default_language(context):\n # this new content is being added\n language = None\n \n- if context is not None and not IPloneSiteRoot.providedBy(context):\n- language = context.Language()\n- if not language:\n+ # Try to get the language from context or parent(s)\n+ while context is not None and not IPloneSiteRoot.providedBy(context):\n+ try:\n+ # Use aq_base so the .language attribute isn\'t acquired from root\n+ language = context.aq_base.Language()\n+ except AttributeError: # Accesses .language\n # If we are here, it means we were editing an object that didn\'t\n # have its language set or that the container where we were adding\n # the new content didn\'t have a language set. So we check its\n- # parent, unless we are at site\'s root, in which case we get site\'s\n- # default language\n- if not IPloneSiteRoot.providedBy(context.aq_parent):\n- language = context.aq_parent.Language()\n+ # parent.\n+ context = context.__parent__\n+\n+ pl = getToolByName(getSite(), \'portal_languages\')\n+ default_language = pl.getDefaultLanguage()\n \n if not language:\n- # Finally, if we still don\'t have a language, then just use site\'s\n- # default\n- pl = getToolByName(getSite(), "portal_languages")\n- language = pl.getDefaultLanguage()\n+ language = default_language\n+\n+ # Is the language supported/enabled at all?\n+ if language not in pl.getAvailableLanguages():\n+ language = default_language\n \n return language\n \n' | ||
|
||
Case in point: the 3.7-6.0 tests currently fail because `bin/test-no-uncommitted-doc-changes` is not found: | ||
https://github.com/plone/plone.restapi/pull/1414#issuecomment-1120897719 | ||
Repository: plone.app.dexterity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-05-09T15:36:08+02:00 | ||
Author: Peter Holzer (agitator) <peter.holzer@agitator.com> | ||
Commit: https://github.com/plone/plone.app.dexterity/commit/3e57847488981bd7dcba9dd07e6a7399bbd4b5a6 | ||
|
||
add news | ||
|
||
Files changed: | ||
A test-no-sphinx-warnings | ||
A test-no-uncommitted-doc-changes | ||
M .github/workflows/tests.yml | ||
M base.cfg | ||
D test-no-sphinx-warnings.in | ||
D test-no-uncommitted-doc-changes.in | ||
A news/350.bugfix | ||
|
||
b'diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml\nindex 9fdf80b32..62516686e 100644\n--- a/.github/workflows/tests.yml\n+++ b/.github/workflows/tests.yml\n@@ -65,11 +65,11 @@ jobs:\n \n # test no uncommited changes\n - name: test no uncommited changes\n- run: bin/test-no-uncommitted-doc-changes\n+ run: ./test-no-uncommitted-doc-changes\n env:\n PYTHON_VERSION: ${{ matrix.python-version }}\n PLONE_VERSION: ${{ matrix.plone-version }}\n \n # test sphinx warnings\n # - name: sphinx\n-# run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == \'3.7\' ]; then bin/test-no-sphinx-warnings; fi\n+# run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == \'3.7\' ]; then ./test-no-sphinx-warnings; fi\ndiff --git a/base.cfg b/base.cfg\nindex 8f22ca372..33f786f8e 100644\n--- a/base.cfg\n+++ b/base.cfg\n@@ -5,8 +5,6 @@ parts =\n instance\n test\n test-coverage\n- test-no-uncommitted-doc-changes\n- test-no-sphinx-warnings\n code-analysis\n dependencychecker\n dependencies\n@@ -87,18 +85,6 @@ input = inline:\n output = ${buildout:directory}/bin/test-coverage\n mode = 755\n \n-[test-no-uncommitted-doc-changes]\n-recipe = collective.recipe.template\n-input = test-no-uncommitted-doc-changes.in\n-output = bin/test-no-uncommitted-doc-changes\n-mode = 755\n-\n-[test-no-sphinx-warnings]\n-recipe = collective.recipe.template\n-input = test-no-sphinx-warnings.in\n-output = bin/test-no-sphinx-warnings\n-mode = 755\n-\n [code-analysis]\n recipe = plone.recipe.codeanalysis\n directory = ${buildout:directory}/src\ndiff --git a/test-no-sphinx-warnings.in b/test-no-sphinx-warnings\nsimilarity index 100%\nrename from test-no-sphinx-warnings.in\nrename to test-no-sphinx-warnings\ndiff --git a/test-no-uncommitted-doc-changes.in b/test-no-uncommitted-doc-changes\nsimilarity index 100%\nrename from test-no-uncommitted-doc-changes.in\nrename to test-no-uncommitted-doc-changes\n' | ||
b"diff --git a/news/350.bugfix b/news/350.bugfix\nnew file mode 100644\nindex 00000000..0c3733b2\n--- /dev/null\n+++ b/news/350.bugfix\n@@ -0,0 +1,4 @@\n+\n+Don't acquire lanuage from portal root default_language for ICategorization.language.\n+Fixes https://github.com/plone/plone.app.dexterity/issues/258\n+[jaroel]\n\\ No newline at end of file\n" | ||
|
||
Repository: plone.restapi | ||
Repository: plone.app.dexterity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-05-09T15:03:17+02:00 | ||
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> | ||
Commit: https://github.com/plone/plone.restapi/commit/4f4101c229ee238b1b957e902fbacdced1439301 | ||
Date: 2022-05-09T18:37:12+02:00 | ||
Author: Peter Holzer (agitator) <peter.holzer@agitator.com> | ||
Commit: https://github.com/plone/plone.app.dexterity/commit/e0cd92002acd6f67ce98f1a3347b35bbf0f3f214 | ||
|
||
Merge pull request #1420 from plone/maurits-test-no-script-generation-in-buildout | ||
use getattr | ||
|
||
Files changed: | ||
M plone/app/dexterity/behaviors/metadata.py | ||
|
||
Move the generation of two test scripts out of buildout. | ||
b"diff --git a/plone/app/dexterity/behaviors/metadata.py b/plone/app/dexterity/behaviors/metadata.py\nindex 88555d6..6c75867 100644\n--- a/plone/app/dexterity/behaviors/metadata.py\n+++ b/plone/app/dexterity/behaviors/metadata.py\n@@ -39,25 +39,24 @@ def default_language(context):\n language = None\n \n # Try to get the language from context or parent(s)\n- while context is not None and not IPloneSiteRoot.providedBy(context):\n- try:\n- # Use aq_base so the .language attribute isn't acquired from root\n- language = context.aq_base.Language()\n- except AttributeError: # Accesses .language\n+ while not language and context is not None and not IPloneSiteRoot.providedBy(context):\n+ language = getattr(context.aq_base, 'language', None)\n+\n+ if not language:\n # If we are here, it means we were editing an object that didn't\n # have its language set or that the container where we were adding\n # the new content didn't have a language set. So we check its\n # parent.\n context = context.__parent__\n \n- pl = getToolByName(getSite(), 'portal_languages')\n- default_language = pl.getDefaultLanguage()\n+ language_tool = getToolByName(getSite(), 'portal_languages')\n+ default_language = language_tool.getDefaultLanguage()\n \n if not language:\n language = default_language\n \n # Is the language supported/enabled at all?\n- if language not in pl.getAvailableLanguages():\n+ if language not in language_tool.getAvailableLanguages():\n language = default_language\n \n return language\n" | ||
|
||
Repository: plone.app.dexterity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-05-09T21:42:12+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.app.dexterity/commit/692d932f796801325679383aeb384bf4e15ac106 | ||
|
||
Merge pull request #350 from plone/defaultlanglookup | ||
|
||
[6.0] Don't acquire .language from portal root. | ||
|
||
Files changed: | ||
A test-no-sphinx-warnings | ||
A test-no-uncommitted-doc-changes | ||
M .github/workflows/tests.yml | ||
M base.cfg | ||
D test-no-sphinx-warnings.in | ||
D test-no-uncommitted-doc-changes.in | ||
|
||
b'diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml\nindex 9fdf80b32..62516686e 100644\n--- a/.github/workflows/tests.yml\n+++ b/.github/workflows/tests.yml\n@@ -65,11 +65,11 @@ jobs:\n \n # test no uncommited changes\n - name: test no uncommited changes\n- run: bin/test-no-uncommitted-doc-changes\n+ run: ./test-no-uncommitted-doc-changes\n env:\n PYTHON_VERSION: ${{ matrix.python-version }}\n PLONE_VERSION: ${{ matrix.plone-version }}\n \n # test sphinx warnings\n # - name: sphinx\n-# run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == \'3.7\' ]; then bin/test-no-sphinx-warnings; fi\n+# run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == \'3.7\' ]; then ./test-no-sphinx-warnings; fi\ndiff --git a/base.cfg b/base.cfg\nindex 8f22ca372..33f786f8e 100644\n--- a/base.cfg\n+++ b/base.cfg\n@@ -5,8 +5,6 @@ parts =\n instance\n test\n test-coverage\n- test-no-uncommitted-doc-changes\n- test-no-sphinx-warnings\n code-analysis\n dependencychecker\n dependencies\n@@ -87,18 +85,6 @@ input = inline:\n output = ${buildout:directory}/bin/test-coverage\n mode = 755\n \n-[test-no-uncommitted-doc-changes]\n-recipe = collective.recipe.template\n-input = test-no-uncommitted-doc-changes.in\n-output = bin/test-no-uncommitted-doc-changes\n-mode = 755\n-\n-[test-no-sphinx-warnings]\n-recipe = collective.recipe.template\n-input = test-no-sphinx-warnings.in\n-output = bin/test-no-sphinx-warnings\n-mode = 755\n-\n [code-analysis]\n recipe = plone.recipe.codeanalysis\n directory = ${buildout:directory}/src\ndiff --git a/test-no-sphinx-warnings.in b/test-no-sphinx-warnings\nsimilarity index 100%\nrename from test-no-sphinx-warnings.in\nrename to test-no-sphinx-warnings\ndiff --git a/test-no-uncommitted-doc-changes.in b/test-no-uncommitted-doc-changes\nsimilarity index 100%\nrename from test-no-uncommitted-doc-changes.in\nrename to test-no-uncommitted-doc-changes\n' | ||
A news/350.bugfix | ||
M plone/app/dexterity/behaviors/metadata.py | ||
|
||
b'diff --git a/news/350.bugfix b/news/350.bugfix\nnew file mode 100644\nindex 00000000..0c3733b2\n--- /dev/null\n+++ b/news/350.bugfix\n@@ -0,0 +1,4 @@\n+\n+Don\'t acquire lanuage from portal root default_language for ICategorization.language.\n+Fixes https://github.com/plone/plone.app.dexterity/issues/258\n+[jaroel]\n\\ No newline at end of file\ndiff --git a/plone/app/dexterity/behaviors/metadata.py b/plone/app/dexterity/behaviors/metadata.py\nindex 8eabe5b0..6c758676 100644\n--- a/plone/app/dexterity/behaviors/metadata.py\n+++ b/plone/app/dexterity/behaviors/metadata.py\n@@ -38,22 +38,26 @@ def default_language(context):\n # this new content is being added\n language = None\n \n- if context is not None and not IPloneSiteRoot.providedBy(context):\n- language = context.Language()\n+ # Try to get the language from context or parent(s)\n+ while not language and context is not None and not IPloneSiteRoot.providedBy(context):\n+ language = getattr(context.aq_base, \'language\', None)\n+\n if not language:\n # If we are here, it means we were editing an object that didn\'t\n # have its language set or that the container where we were adding\n # the new content didn\'t have a language set. So we check its\n- # parent, unless we are at site\'s root, in which case we get site\'s\n- # default language\n- if not IPloneSiteRoot.providedBy(context.aq_parent):\n- language = context.aq_parent.Language()\n+ # parent.\n+ context = context.__parent__\n+\n+ language_tool = getToolByName(getSite(), \'portal_languages\')\n+ default_language = language_tool.getDefaultLanguage()\n \n if not language:\n- # Finally, if we still don\'t have a language, then just use site\'s\n- # default\n- pl = getToolByName(getSite(), "portal_languages")\n- language = pl.getDefaultLanguage()\n+ language = default_language\n+\n+ # Is the language supported/enabled at all?\n+ if language not in language_tool.getAvailableLanguages():\n+ language = default_language\n \n return language\n \n' | ||
|