-
-
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.
Branch: refs/heads/main Date: 2022-04-28T00:23:30+02:00 Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> Commit: plone/plone.base@c84d32a move _createObjectByType as unrestricted_construct_instance to here Files changed: A news/8.feature M src/plone/base/utils.py Repository: plone.base Branch: refs/heads/main Date: 2022-04-30T11:58:59+02:00 Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> Commit: plone/plone.base@01c8e58 Merge pull request #8 from plone/unrestricted_construct_instance move _createObjectByType as unrestricted_construct_instance to here Files changed: A news/8.feature M src/plone/base/utils.py
- Loading branch information
Showing
1 changed file
with
26 additions
and
14 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,22 +1,34 @@ | ||
Repository: plone.restapi | ||
Repository: plone.base | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-04-30T07:06:31+02:00 | ||
Author: Andreas Jung (zopyx) <info@zopyx.com> | ||
Commit: https://github.com/plone/plone.restapi/commit/43d5f61e7c3320de3fad03a6d5850f5c9bb17c7c | ||
Branch: refs/heads/main | ||
Date: 2022-04-28T00:23:30+02:00 | ||
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> | ||
Commit: https://github.com/plone/plone.base/commit/c84d32aa695bb84e4a71143dc1fd05dab2559df3 | ||
|
||
Better term lookup error logging (#1366) | ||
move _createObjectByType as unrestricted_construct_instance to here | ||
|
||
* added | ||
|
||
* better error logging for Term lookup errors | ||
|
||
* blacke-ed | ||
Files changed: | ||
A news/8.feature | ||
M src/plone/base/utils.py | ||
|
||
b'diff --git a/news/8.feature b/news/8.feature\nnew file mode 100644\nindex 0000000..f555495\n--- /dev/null\n+++ b/news/8.feature\n@@ -0,0 +1,2 @@\n+Move `Products.CMFPlone.utils._createObjectByType to here as `utils.unrestricted_construct_instance`.\n+[jensens]\ndiff --git a/src/plone/base/utils.py b/src/plone/base/utils.py\nindex 4669757..b714278 100644\n--- a/src/plone/base/utils.py\n+++ b/src/plone/base/utils.py\n@@ -509,3 +509,23 @@ def get_user_friendly_types(types_list=None):\n types = {t for t in types_list if t in types}\n friendly_types = types - set(search_settings.types_not_searched)\n return list(friendly_types)\n+\n+\n+def unrestricted_construct_instance(type_name, container, id, *args, **kw):\n+ """Create an object without performing security checks\n+\n+ invokeFactory and fti.constructInstance perform some security checks\n+ before creating the object. Use this function instead if you need to\n+ skip these checks.\n+\n+ This method uses\n+ CMFCore.TypesTool.FactoryTypeInformation._constructInstance\n+ to create the object without security checks.\n+ """\n+ id = str(id)\n+ typesTool = getToolByName(container, \'portal_types\')\n+ fti = typesTool.getTypeInfo(type_name)\n+ if not fti:\n+ raise ValueError(\'Invalid type %s\' % type_name)\n+\n+ return fti._constructInstance(container, id, *args, **kw)\n' | ||
|
||
Repository: plone.base | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2022-04-30T11:58:59+02:00 | ||
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> | ||
Commit: https://github.com/plone/plone.base/commit/01c8e58dcf4f0089cf8be0839b1c783dde7d0dba | ||
|
||
Merge pull request #8 from plone/unrestricted_construct_instance | ||
|
||
move _createObjectByType as unrestricted_construct_instance to here | ||
|
||
Files changed: | ||
A news/1365.feature | ||
M src/plone/restapi/serializer/dxfields.py | ||
A news/8.feature | ||
M src/plone/base/utils.py | ||
|
||
b'diff --git a/news/1365.feature b/news/1365.feature\nnew file mode 100644\nindex 000000000..9724e0544\n--- /dev/null\n+++ b/news/1365.feature\n@@ -0,0 +1,2 @@\n+better error logging for term lookup errors\n+[ajung]\ndiff --git a/src/plone/restapi/serializer/dxfields.py b/src/plone/restapi/serializer/dxfields.py\nindex de04b387e..86eed9adc 100644\n--- a/src/plone/restapi/serializer/dxfields.py\n+++ b/src/plone/restapi/serializer/dxfields.py\n@@ -82,7 +82,15 @@ def __call__(self):\n term = value_type.vocabulary.getTerm(v)\n values.append({"token": term.token, "title": term.title})\n except LookupError:\n- log.warning("Term lookup error: %r" % v)\n+ log.warning(\n+ "Term lookup error: %r %s (%s:%s)"\n+ % (\n+ v,\n+ self.field.title,\n+ self.context.portal_type,\n+ self.context.absolute_url(1),\n+ )\n+ )\n value = values\n return json_compatible(value)\n \n' | ||
b'diff --git a/news/8.feature b/news/8.feature\nnew file mode 100644\nindex 0000000..f555495\n--- /dev/null\n+++ b/news/8.feature\n@@ -0,0 +1,2 @@\n+Move `Products.CMFPlone.utils._createObjectByType to here as `utils.unrestricted_construct_instance`.\n+[jensens]\ndiff --git a/src/plone/base/utils.py b/src/plone/base/utils.py\nindex 4669757..b714278 100644\n--- a/src/plone/base/utils.py\n+++ b/src/plone/base/utils.py\n@@ -509,3 +509,23 @@ def get_user_friendly_types(types_list=None):\n types = {t for t in types_list if t in types}\n friendly_types = types - set(search_settings.types_not_searched)\n return list(friendly_types)\n+\n+\n+def unrestricted_construct_instance(type_name, container, id, *args, **kw):\n+ """Create an object without performing security checks\n+\n+ invokeFactory and fti.constructInstance perform some security checks\n+ before creating the object. Use this function instead if you need to\n+ skip these checks.\n+\n+ This method uses\n+ CMFCore.TypesTool.FactoryTypeInformation._constructInstance\n+ to create the object without security checks.\n+ """\n+ id = str(id)\n+ typesTool = getToolByName(container, \'portal_types\')\n+ fti = typesTool.getTypeInfo(type_name)\n+ if not fti:\n+ raise ValueError(\'Invalid type %s\' % type_name)\n+\n+ return fti._constructInstance(container, id, *args, **kw)\n' | ||
|