[Zope-CMF] Get list of published items that user has access to

davelehman@loewen.com davelehman@loewen.com
Mon, 12 Nov 2001 10:50:44 -0600


Hmm... this doesn't seem to actually work. That is, you're correct that the
"expired" content automatically doesn't show up for normal members, but for
my "editors" that have the "access inactive portal content" right, the
expired content still shows up, even when i'm trying to expressly filter it
out.

<dtml-in "portal_catalog.searchResults( meta_type=['Document','News
Item','CMF Event']
                                      , sort_on='Date'
                                      , sort_order='reverse'
                                      , review_state='published'
                                      , expires=ZopeTime()
                                      , expires_usage='range:min'
                                      , effective=ZopeTime()
                                      , effective_usage='range:max'
                                      , path=news_path
                                      )" size="5">

Interestingly enough, the "effective" filter seems to work, but "expires"
does not. So it *does* filter out items that have a future effective date,
but *does not* filter out items that have a past expiry date. Is this a
bug?

--dave


On 11/12/2001 10:25:45 AM Tres Seaverwrote:

>On Mon, 12 Nov 2001 davelehman@loewen.com wrote:
>
>>
>> On 10/22/2001 08:56:01 PM Tres Seaverwrote:
>>
>> >You can also explicitly add it to your query:
>> >
>> >   <dtml-in expr="portal_catalog( ....
>> >                                , effective=ZopeTime()
>> >                                , effective_usage="range:min"
>> >                                )">
>>
>> Um, sorry to be totally dense, but how do I also get it to honor the
expiry
>> date? Can I just do something like this?
>>
>> <dtml-in expr="portal_catalog( ....
>>                             , effective=ZopeTime()
>>                             , effective_usage="range:min"
>>                             , expiry=ZopeTime()
>>                             , expiry_usage="range:max"
>>                             )">
>
>If the current user doesn't have the 'Access inactive portal content'
>permission, then both effective and expiration are automatically added
>to the catalog query::
>
>    #
>    #   CMFCore.CatalogTool.py
>    #
>    def searchResults(self, REQUEST=None, **kw):
>        """
>            Calls ZCatalog.searchResults with extra arguments that
>            limit the results to what the user is allowed to see.
>        """
>        user = _getAuthenticatedUser(self)
>        kw['allowedRolesAndUsers'] = list(user.getRoles()) + \
>                                     ['Anonymous',
>                                      'user:'+user.getUserName()]
>        if not _checkPermission(
>            CMFCorePermissions.AccessInactivePortalContent, self ):
>            kw[ 'effective' ] = kw[ 'expires' ] = DateTime()
>            kw['effective_usage'] = 'range:max'
>            kw['expires_usage'] = 'range:min'
>
>        return apply(ZCatalog.searchResults, (self, REQUEST), kw)
>
>If you want to apply that filter, even for managers or reviewers,
>use the 'expires' index, as above.
>
>Tres.
>--
>===============================================================
>Tres Seaver                                tseaver@zope.com
>Zope Corporation      "Zope Dealers"       http://www.zope.com
>