diff options
| author | Rob Miller <rob@mochimedia.com> | 2010-12-29 14:12:30 -0800 |
|---|---|---|
| committer | Rob Miller <rob@mochimedia.com> | 2010-12-29 14:12:30 -0800 |
| commit | 9c1d34a3de11286c98dce52592ef05a3c05046a5 (patch) | |
| tree | 3b9d60fabfa876bdaba9debd477f85cd9cf926bf /docs/tutorials/cmf/catalog.rst | |
| parent | 88231cc1b16f1f5a0983dba1dab9b401bbde0c00 (diff) | |
| parent | 8739f576ed84bb48cec9c2d4b60e92878a273b1f (diff) | |
| download | pyramid-9c1d34a3de11286c98dce52592ef05a3c05046a5.tar.gz pyramid-9c1d34a3de11286c98dce52592ef05a3c05046a5.tar.bz2 pyramid-9c1d34a3de11286c98dce52592ef05a3c05046a5.zip | |
Merge remote branch 'refs/remotes/upstream/viewderiver' into ra_view_decoration
Conflicts:
CHANGES.txt
pyramid/config.py
Diffstat (limited to 'docs/tutorials/cmf/catalog.rst')
| -rw-r--r-- | docs/tutorials/cmf/catalog.rst | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/docs/tutorials/cmf/catalog.rst b/docs/tutorials/cmf/catalog.rst deleted file mode 100644 index d5e9534ae..000000000 --- a/docs/tutorials/cmf/catalog.rst +++ /dev/null @@ -1,73 +0,0 @@ -.. _catalog_chapter: - -======= -Catalog -======= - -The main feature of the CMF catalog is that it filters search results -from the Zope 2 "catalog" based on the requesting user's ability to -view a particular cataloged object. - -:app:`Pyramid` itself has no cataloging facility, but an addon -package named :term:`repoze.catalog` offers similar functionality. - -Creating an Allowed Index -------------------------- - -In CMF, a catalog index named ``getAllowedRolesAndUsers`` along with -application indexing code allows for filtered search results. It's -reasonably easy to reproduce this pattern using some custom code. - -Creating The ``allowed`` Index -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here's some code which creates an ``allowed`` index for use in a -``repoze.catalog`` catalog:: - - from pyramid.security import principals_allowed_by_permission - from repoze.catalog.indexes.keyword import CatalogKeywordIndex - from repoze.catalog.catalog import Catalog - - class Allowed: - def __init__(self, permission): - self.permission = permission - - def __call__(self, context, default): - principals = principals_allowed_by_permission(context, - self.permission) - return principals - - def make_allowed_index(permission='View'): - index = CatalogKeywordIndex(Allowed(permission)) - return index - - index = make_allowed_index() - catalog = Catalog() - catalog['allowed'] = index - -When you index an item, the allowed index will be populated with all -the principal ids which have the 'View' permission. - -Using the ``allowed`` Index -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here's how you might use the ``allowed`` index within a query:: - - from pyramid.security import effective_principals - principals = effective_principals(request) - catalog.searchResults(allowed={'operator':'or', 'query':principals}) - -The above query will return all document ids that the current user has -the 'View' permission against. Add other indexes to the query to get -a useful result. - -See the `repoze.catalog package -<http://svn.repoze.org/repoze.catalog/trunk>`_ for more information. - - - - - - - - |
