Commit 48cfa07a authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Folder: fix objectValues(portal_type=...).

For example, Web Section can contain a Script (Python) to set Access
Rule, but the parent section's objectValues(portal_type='Web Section')
should not include such object.
parent 2e67044a
......@@ -1542,7 +1542,7 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
if portal_type is not None:
if isinstance(portal_type, str):
portal_type = (portal_type,)
object_list = [x for x in object_list if x.getPortalType() in portal_type]
object_list = [x for x in object_list if getattr(aq_base(x), 'getPortalType', lambda: None)() in portal_type]
if checked_permission is not None:
checkPermission = getSecurityManager().checkPermission
object_list = [o for o in object_list
......
......@@ -37,7 +37,7 @@ import warnings
from Acquisition import aq_base
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.ZopeGuards import guarded_import
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.tests.utils import LogInterceptor, createZODBPythonScript
class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
"""
......@@ -283,6 +283,12 @@ class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
warnings.warn('user warning', DeprecationWarning)
self.assertEqual(self.logged[-1].name, 'DeprecationWarning')
def test_objectValues(self):
person = self.portal.person_module.newContent(portal_type='Person')
createZODBPythonScript(person, 'script', '', '')
script = person['script']
self.assertIn(script, person.objectValues())
self.assertNotIn(script, person.objectValues(portal_type='Person'))
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment