Personal tools
You are here: Home Products pluggablecatalog
Navigation
Log in


Forgot your password?
New user?
 
Document Actions

pluggablecatalog

RSS Feed Category: Development tools, Miscellaneous — Other products by this author
pluggablecatalog is a replacement (or rather: a wrapper) for Plone's portal catalog. It adds the ability to plug in search restrictions without the need to subclass or monkey- patch the catalog.

Current release: pluggablecatalog 1.0

Released Jul 24, 2008 — tested with Plone 3.1, Plone 3.0, Plone 2.5

Release of the newly eggified version of Products.pluggablecatalog.

List all releases… Full release announcement…

Get pluggablecatalog for all platforms (11KB)

Product Source Distribution

Experimental releases

There are no experimental releases available at the moment.

Project Description

Project resources

This is the tool's docstring showing one example usage. Using the pluggablecatalog is as simple as defining your own IQueryDefaults utility. More plugin points are planned:

Wraps CMFPlone's CatalogTool to add default parameters
collected from IQueryDefaults utilities.

Install the catalog:

  >>> from StringIO import StringIO
  >>> from Products.pluggablecatalog.Extensions.install \
  ...     import _replaceCatalog
  >>> self.loginAsPortalOwner()
  >>> _replaceCatalog(self.portal, StringIO())
  >>> self.login()

  >>> from Products.pluggablecatalog.tool import CatalogTool
  >>> catalog = self.portal.portal_catalog
  >>> isinstance(catalog, CatalogTool)
  True

We create two documents and make sure they're indexed:

  >>> before = len(catalog())
  >>> self.folder.invokeFactory('Document', 'doc1')
  'doc1'
  >>> self.folder.invokeFactory('Document', 'doc2')
  'doc2'
  >>> doc1, doc2 = self.folder.doc1, self.folder.doc2
  >>> doc1.setTitle('First Document')
  >>> doc2.setTitle('Second Document')
  >>> doc1.reindexObject(); doc2.reindexObject()
  >>> len(catalog()) - before
  2

Let's now add a rather stupid IQueryDefaults utility that
restricts searches by default to objects with the Title 'First
Document':

  >>> from zope import component
  >>> from zope import interface
  >>> from Products.pluggablecatalog.interfaces import IQueryDefaults
  >>> def myDefaults(context, request):
  ...     return {'Title': 'First Document'}
  >>> interface.directlyProvides(myDefaults, IQueryDefaults)
  >>> component.provideUtility(myDefaults)

With this utility in place, we should only retrieve doc1 now,
unless we explicitly provide a 'Title' query parameter:

  >>> len(catalog())
  1
  >>> catalog()[0].getObject().aq_base is doc1.aq_base
  True

  >>> len(catalog(Title='Second Document'))
  1
  >>> (catalog(Title='Second Document')[0].getObject().aq_base is
  ...  doc2.aq_base)
  True
by Daniel Nouri last modified June 25, 2006 - 17:27

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by