Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install anthill.querytool

How to install anthill.querytool

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install anthill.querytool
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
Windows (64-bit)
0.2 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
Linux (32-bit)
0.2 Available View build log
Linux (64-bit)
0.2 Available View build log
Lastest release
version 0.2 on Jan 5th, 2011


This package provides a complete user interface for AdvancedQuery by Dieter Maurer. It enables you to use a powerful language to search for content. It also provides functionality to save parametrized and conditional queries for later use (predefined queries). Look at the examples for more information.


  • Put anthill.querytool in eggs= and zcml=
  • Make sure that AdvancedQuery is installed (works for Plone 3.x)

Example query

A query could look like that:

System Message: WARNING/2 (<string>, line 20)

Literal block expected; none found.

And( Eq('SearchableText', '$text'), ~Generic('path', {'query':'Members', 'level':-1}),

[[if($allowed_types)]] In('portal_types', $allowed_types), [[endif]]

[[ifnot($allowed_types)]] In('portal_types', ['Folder', 'Document']), [[endif]]

Ge('start_date', TODAY) )

Here you see that you can parametrize queries (variable expansion enabled using $), you also can use defined constants (only one currently active called TODAY where TODAY=DateTime()) and you can put conditionals in your queries.

Conditionals are a powerful way to enable or disable certain parts of your query. The if statement checks if a given parameter exists. You can also replace if with ifnot that only activates the given part if the parameter is not set.

You can save this query and call it later on like that:

System Message: WARNING/2 (<string>, line 46)

Literal block expected; none found.

context.query_tool.executePredefinedQuery('contentsearch', text='Test*', allowed_types=['Folder', ])


This release adds some additional query operators (defined in SearchOperators.py). The following operators are currently available:

  • Count counts items in search results. (e.g. Count(Eq('SearchableText', 'moses')) )
  • Sum computes sum over int result (e.g. Sum(Ge('commentcount', 10)) )
  • Avg computes the average over an int result (e.g. Avg(Ge('userviews', 1)) )

Look at SearchOperators.py for examples on how to create your own operators.

Submit query


Predefined queries



  • Dieter Maurer for his great implementation of AdvancedQuery
  • Markus Reinsch for providing useful hints and code

0.2 - 2009/08/21

  • Revamped documentation [spamsch]

0.1 - 2009/08/20

  • Initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.