[Zope] Multiple DTML-questions
Samu Mielonen
ex@uiah.fi
Thu, 14 Oct 1999 13:45:33 +0300
Hello,
I have multiple problems with a short DTML thingy I'm
putting together. Let's go through them one at a time.
I have folder hierarchy (from KM|NetNews) like this
ArticleStorage
Year
Month_x
Month_y
...
Day_p
Day_q
Day_r
...
Article1_id
Article2_id
Article3_id
So, year, date, month and article are all folderish objects that
contain further objects (article contains images that have been
submitted alongside the article itself).
I have a rudimentary (copied) dtml-code that displays all articles
(from any year, month, day):
<dtml-in "objectValues('KMYear')">
<dtml-in "objectValues('KMMonth')">
<dtml-in "objectValues('KMArticle')" sort=release reverse>
<dtml-if "(release.isPast()) and current">
<H1><dtml-var title></H2>
<A HREF="mailto:<dtml-var email>"><dtml-var author></A>
<BR>
<dtml-var teaser>
<br>
<dtml-if "text_content">
<a href="<dtml-var "absolute_url() +'/index.html'">">Read
more...</a>
</dtml-if>
<P>
</dtml-if>
</dtml-in>
</dtml-in>
</dtml-in>
So, nothing fancy in that. It looks through all the year objects
and through all month objects and through all the day objects and
displays all articles that have a release date (release-variable)
past now and that are current (curret variable is set to 1).
Easy, at least that's how I understand it (i.e. ObjectValues(X) looks
through all the subfolders of type X??). There is no good documentation
for objectValues anywhere in the DTML Guide (just 2 obscure examples
and one reference in index).
Now, to my problems:
1. I want to display only articles from year_x, month_x, day_x.
Can I somehow only list articles from year_x/mont_x/day_x? How?
I can't find any command nor reference how to do this via objectValues.
I don't want to make an if-loop inside the above original code that
check for all articles (regardless of their folder) that if theyr
year, mont and day are the same as today. This would require 3 if
statements for ALL of my articles. This would be silly, dont you think?
2. I have a method from KM|NetNews product called add.html
and another one called approve.html (these are my modified
copies of incoming.html and index.html respectively).
I want users with writer role to access add.html and add.html
ONLY. I want users with editor role to access add.html and
approve.html. Both of these methods are under the KMArticleStorage
product folder
How do I do this? I can't find anywhere in the documentation
ways to define permissions for a single dtml_method (call me thick,
but I can't find it!). Also, trying to check the authenticated user
with has_role only results in key_error every single time (works on
one page, doesn't work on another. There is some peculiar namespace
trickery going on here that I don't understand.).
3. If I want to render visible objects that are inside objects
(e.g. images that are inside particular folderish article
objects), how do I do it?
I understand that I can iterate through all of the
folder objects (e.g. images) and display their id, the actual
image itself and then even give a form submit button to
upload a file to replace that image.
But I can't figure out the DTML code to do this... I've
tried a gazilliion different permutations (with, let,
objectvalues, sequence-item, etc. tags)
Any takers?
All help mucho appreciated,
Samu Mielonen
PS About my earlier e-mail about Zope consulting. Yes, I'm buying that,
but it's goingg to take awhile to produce anything so I need to get
up running quickly with my mini-mini-mini-version. This is why I'm
still fighting with DTML :)
--
"The world will not evolve past its current state of crisis
by using the same thinking that created the situation." - Albert Einstein