catalog – Cataloging Components Module

Components to help cataloging and searching objects.

class waeup.kofa.catalog.FilteredCatalogQueryBase(**kw)[source]

Bases: waeup.kofa.catalog.FilteredQueryBase

Base for filtered queries based on catalog lookups.

This type of query asks a catalog to find objects.

You would normally use this type of query like this:

>>> query = FilteredCatalogQueryBase(name='bob')
>>> objects = query.query()

The name of the catalog to use can be set via cat_name attribute.

Looked up are all objects that match keywords passed to constructor where the keyword names must match a certain index of the chosen catalog. So, if some catalog has indexes name and age, then keywords name=’bob’, age=‘12’ would search for all objects with name bob and age 12.

This query supports single values (exact matches) and ranges of values passed in via (min_value, max_value) tuples. So, constructor keyword args name=(‘a’, ‘d’) would find objects with name alice, bob, d, but not donald, john, or zak.

__doc__ = "Base for filtered queries based on catalog lookups.\n\n This type of query asks a catalog to find objects.\n\n You would normally use this type of query like this:\n\n >>> query = FilteredCatalogQueryBase(name='bob')\n >>> objects = query.query()\n\n The name of the catalog to use can be set via `cat_name`\n attribute.\n\n Looked up are all objects that match keywords passed to\n constructor where the keyword names must match a certain index of\n the chosen catalog. So, if some catalog has indexes `name` and\n `age`, then keywords `name='bob', age='12'` would search for all\n objects with name ``bob`` and age ``12``.\n\n This query supports single values (exact matches) and ranges of\n values passed in via ``(min_value, max_value)`` tuples. So,\n constructor keyword args `name=('a', 'd')` would find objects with\n name ``alice``, ``bob``, ``d``, but not ``donald``, ``john``, or\n ``zak``.\n "
__implemented__ = <implementedBy waeup.kofa.catalog.FilteredCatalogQueryBase>
__module__ = 'waeup.kofa.catalog'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
cat_name = None
query()[source]

Perform a query with parameters passed to constructor.

Returns some iterable, normally a list or a catalog result set.

query_catalog(catalog)[source]

Search catalog.

Use catalog, some Catalog instance, to search objects denoted by constructor keywords.

class waeup.kofa.catalog.FilteredQueryBase(**kw)[source]

Bases: object

A filter to find objects that match certain parameters.

Parameters are passed to constructor as keyword arguments. The real data retrieval then happens when query() is called.

The defaults attribute, a dict, can set certain default values for parameters that are used if the constructor is called without any parameters.

__dict__ = dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.catalog', '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f4027669150>, 'defaults': {}, '__dict__': <attribute '__dict__' of 'FilteredQueryBase' objects>, 'query': <function query at 0x7f4026c04848>, '__implemented__': <implementedBy waeup.kofa.catalog.FilteredQueryBase>, '__weakref__': <attribute '__weakref__' of 'FilteredQueryBase' objects>, '__doc__': 'A filter to find objects that match certain parameters.\n\n Parameters are passed to constructor as keyword arguments. The\n real data retrieval then happens when `query()` is called.\n\n The `defaults` attribute, a dict, can set certain default values\n for parameters that are used if the constructor is called without\n any parameters.\n ', '__init__': <function __init__ at 0x7f4026c049b0>})
__doc__ = 'A filter to find objects that match certain parameters.\n\n Parameters are passed to constructor as keyword arguments. The\n real data retrieval then happens when `query()` is called.\n\n The `defaults` attribute, a dict, can set certain default values\n for parameters that are used if the constructor is called without\n any parameters.\n '
__implemented__ = <implementedBy waeup.kofa.catalog.FilteredQueryBase>
__init__(**kw)[source]
__module__ = 'waeup.kofa.catalog'
__providedBy__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__weakref__

list of weak references to the object (if defined)

defaults = {}
query(context=None)[source]
class waeup.kofa.catalog.KofaQuery[source]

Bases: hurry.query.query.Query

A hurry.query.query.Query compatible query that also supports retrival of plain Bree result sets as used inside a catalog.

Like hurry.query.query.Query objects, KofaQuery is some kind of a meta query or ‘compound query’ that can give the cataloged objects (or their int ids) matching one or more ‘subqueries’.

This way you can search for objects (or their int ids) that match several criteria at the same time. See examples section below.

A singleton instance of this class is also available as global utility.

A hurry.query-like query that supports also apply.

__doc__ = "A `hurry.query.query.Query` compatible query that also supports\n retrival of plain ``Bree`` result sets as used inside a catalog.\n\n Like `hurry.query.query.Query` objects, `KofaQuery` is some kind\n of a meta query or 'compound query' that can give the cataloged\n objects (or their int ids) matching one or more 'subqueries'.\n\n This way you can search for objects (or their int ids) that match\n several criteria at the same time. See ``examples`` section below.\n\n A singleton instance of this class is also available as global\n utility.\n\n A hurry.query-like query that supports also ``apply``.\n "
__implemented__ = <implementedBy waeup.kofa.catalog.KofaQuery>
__module__ = 'waeup.kofa.catalog'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
apply(query)[source]

Get the list of int ids (a BTree result set) for objects determined by query.

The list of int ids is less expensive to compute than the complete search results and sufficient, for instance, when you only need the number of objects that match a query and not the objects themselves.

searchResults(query)[source]

Get a set of ZODB objects conforming to a query.

class waeup.kofa.catalog.QueryResultItem(context, view)[source]

Bases: object

__dict__ = dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.catalog', 'description': None, 'title': None, 'url': None, '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f4027669790>, '__dict__': <attribute '__dict__' of 'QueryResultItem' objects>, '__implemented__': <implementedBy waeup.kofa.catalog.QueryResultItem>, '__weakref__': <attribute '__weakref__' of 'QueryResultItem' objects>, '__doc__': None, '__init__': <function __init__ at 0x7f4026c04668>})
__doc__ = None
__implemented__ = <implementedBy waeup.kofa.catalog.QueryResultItem>
__init__(context, view)[source]
__module__ = 'waeup.kofa.catalog'
__providedBy__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__weakref__

list of weak references to the object (if defined)

description = None
title = None
url = None