Portal catalog search doesn't include child folders

classic Classic list List threaded Threaded
2 messages Options
Dhrubha Dhrubha
Reply | Threaded
Open this post in threaded view
|

Portal catalog search doesn't include child folders

I adapted a script (Python) and a page template from "The Definitive
Guide to Plone." The script, called findDoc.py , iterates through the
portal catalog of a folder that contains subfolders with the following
syntax:

 results = context.portal_catalog.searchResults()

followed by a suite of commands that counts the number of documents by
author.

For some reason, this script succeeds in counting the documents in the
parent folder, but it ignores the documents in the child folders.
Is this normal? If so, what needs to be done to include the child
folders in the interation?

The second problem I'm having is that the page template refers to the
items returned from the findDoc script by calling the name of the script
as follows:

<span tal:repeat="row here/findDoc">

If I had another variable in the script -- for exampe called childFolder
-- how would I refer to that in the page template.

Thanks

Dhruva Hein
VasudevaServer


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
J Cameron Cooper J Cameron Cooper
Reply | Threaded
Open this post in threaded view
|

Re: Portal catalog search doesn't include child folders

Dhrubha wrote:

> I adapted a script (Python) and a page template from "The Definitive
> Guide to Plone." The script, called findDoc.py , iterates through the
> portal catalog of a folder that contains subfolders with the following
> syntax:
>
> results = context.portal_catalog.searchResults()
>
> followed by a suite of commands that counts the number of documents by
> author.
>
> For some reason, this script succeeds in counting the documents in the
> parent folder, but it ignores the documents in the child folders.
> Is this normal? If so, what needs to be done to include the child
> folders in the interation?

This should return all content in the site, anywhere. There must be
something else going on in the code that you did not show us. Bits are
cheap: no need to be frugal.

> The second problem I'm having is that the page template refers to the
> items returned from the findDoc script by calling the name of the script
> as follows:
>
> <span tal:repeat="row here/findDoc">
>
> If I had another variable in the script -- for exampe called childFolder
> -- how would I refer to that in the page template.

In the findDoc script? You can only see, upon calling a method, what it
returns (which in this case is a list). I can think of no programming
language that lets you poke at a called methods namespace.

However, Python is flexible enough to let you return multiple things. If
in your script you say::

   return someList, childFolder

it will return a tuple. Ask the result for its first element, and you
get a list; the second, you get whatever the other thing is.

                --jcc

--
"When you're going through hell, keep going."
Winston Churchill


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users