Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryCatalog.py filters out False boolean value #278

Closed
puittenbroek opened this issue Oct 14, 2014 · 2 comments
Closed

queryCatalog.py filters out False boolean value #278

puittenbroek opened this issue Oct 14, 2014 · 2 comments

Comments

@puittenbroek
Copy link

Steps to reproduce:

Make a new Plone site
Insert following scipts via ZMI into custom

qry = {'is_default_page': False, 'path': {'query':context.getPhysicalPath(), 'depth':1}}
print "Query: {}".format(qry)
query_results = context.getFolderContents(qry)

print "\n\ngetFolderContents results:"
print [x.id for x in query_results]


pc_results = context.portal_catalog(**qry)
print "\n\nportal_catalog results:"
print [x.id for x in pc_results]

return printed

And run it, result is:

Query: {'path': {'query': ('', 'Plone'), 'depth': 1}, 'is_default_page': False}


getFolderContents results:
['front-page', 'news', 'events', 'Members']


portal_catalog results:
['news', 'events', 'Members']   

Expected results is that both lists are the same. But in queryCatalog.y it does the following:

for k in REQUEST.keys():
    if k in ('SESSION',):
        continue
    v = REQUEST.get(k)
    if v and k in indexes:

Which means that any value that is a pythonic False gets filtered out, including an actual False.
This is present in 4.3.3 and also master branch here on github.

@ale-rt
Copy link
Member

ale-rt commented Aug 24, 2022

This is still an issue for Plone 6.

I adapted the script:

qry = {'is_default_page': False, 'path': {'query': "/".join(context.getPhysicalPath()), 'depth':1}}
print("Query: {}".format(qry))
query_results = context.getFolderContents(qry)

print("\n\ngetFolderContents results:")
print([x.id for x in query_results])

pc_results = context.portal_catalog(**qry)
print("\n\nportal_catalog results:")
print([x.id for x in pc_results])

return printed

Created a folder with a default page on https://6-classic.demo.plone.org/ and ran it:

Query: {'is_default_page': False, 'path': {'query': '/Plone/en/demo/folder-with-default-page', 'depth': 1}}

getFolderContents results:
['default-page-for-folder']


portal_catalog results:
[]

@mauritsvanrees mauritsvanrees removed this from the Plone 4.3 milestone Aug 24, 2022
@jensens jensens added this to the Plone 6.1 milestone Mar 12, 2023
@jensens
Copy link
Member

jensens commented May 16, 2024

this script will be removed in Plone 6.1

@jensens jensens closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants