[Zope-CMF] Re: Listing published items in CMF folder (Frank Bennett)
Carl Rendell
cer@sol43.com
Sun, 19 May 2002 15:38:57 -0700
Sorry about the previous reply.. I missed the subject some how.
I'll try again.
Frank,
You did not indicate if you were using page templates or dtml? In
the case of rendering content from folders I usually end up using
objectValues() or objectItems(). This can be done in both dtml and
zpt, though the implementation of 'filters' for security and review
state are different
ZPT
tal:define"
raw_items python:here.folderName.objectValues('meta_type');
items python:modules['ZTUtils'].LazyFilter( raw_items, skip='')"
Batch process as usual. The LazyFilter takes care of all the
filtering for you in this case. You can access review state for an
item in this context via workflow as follows -
tal:define="
review_state python:items.portal_workflow.getInfoFor(items,
'review_state', '')"
DTML
<dtml-in expr="folderName.objectValues('meta_type')" sort="id"
skip_unauthorized>
Use DTML batch processing techniques and let 'skip_unathorized'
take care of the security issues. To examine the review state in
this context I might use a try -
<dtml-try>
<dtml-call expr="portal_workflow.getInfoFor(this(),
'review_state', '')">
<dtml-except>
<dtml-comment>
Does nothing if the object is not in a review state that the
user is not allowed to view
</dtml-comment>
<dtml-else>
<dtml-comment>
Do what ever processing you wish with the objects
</dtml-comment>
</dtml-try>
The other thing you may want to test is effectivity if you are
controlling the view of objects with time. You did not say anything
about that so I'll leave that part off for now.
On Saturday, May 18, 2002, at 09:00 AM, zope-cmf-request@zope.org
wrote:
>From: Frank Bennett <bennett@nomolog.nagoya-u.ac.jp>
>To: zope-cmf@zope.org
>Subject: [Zope-CMF] Listing published items in CMF folder
>
>In CMF 1.2, Zope 2.4.
>
>For a newsletter, I have used CMF's built-in news facility to
>generate and
>provide editorial workflow for the content.
>
>I want to provide two views of the newsletter: one of recently
>posted items,
>and another of past issues. The first is easy, of course. The
>second is the
>subject of this query.
>
>The final versions of the articles go into a single hierarchy, and
>I have set
>up a couple of page templates that parse the hierarchy and
>metadata to produce
>a list of issues and tables of contents for each.
>
>The table of contents is modelled on the recent_news.pt template.
>I subbed in
>a call on listFolderContents for the searchResults used in the
>original, and
>it works -- but demands a password if any item in the target
>folder is not in
>'published' review state.
>
>I want such items to fail silently instead. I have tried two
>approaches (with
>much blind fumbling about). The first sought to get the objects
>themselves
>and examine them to see if they were in published review state.
>This failed
>because manager was denied permission to load "getReviewStateOf" from
>DefaultWorkflow.py in a simple script.
>
>The second approach involved using searchResults with a path
>parameter to
>limit the scope of the search. searchResults(path='<x>') (where
><x> was set
>to various trial values) seems to show promise, but so far, it
>only delivers
>one of everything-on-the-system or nothing.
>
>I know that the cleaner solution will be to stamp each article
>with metadata
>indicating the issue in which it was published, and having wasted
>a good deal
>of time trying to do it the wrong way, I have seen the light. But this
>problem has gotten under my skin today, and I am curious what the
>solution is.
>
>Frank Bennett
>Nagoya University
>Japan
>
Carl E. Rendell
Solution43
Information Distribution Consulting | "Ahhhh the power of
cer@sol43.com | acquisition" - Chef Z