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
Samu Mielonen wrote:
Easy, at least that's how I understand it (i.e. ObjectValues(X) looks through all the subfolders of type X??).
objectValues(X) returns all objects in the current object manager (ie, folder) of meta_type 'X'. 'X' can be a string or list of strings specifying multiple meta_types. Other similar methods are objectIds(X), which returns a list the of of sub-objects of meta_type X, and objectItems, which returns a list of (id, object) tuples.
There is no good documentation for objectValues anywhere in the DTML Guide (just 2 obscure examples and one reference in index).
You're right, there used to be some decent documentation in the broken help system, which is at the moment being re-engineered, want to write a short how-to on objectValues and it's siblings?
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.
<dtml-with year_x> <dtml-with month_x> <dtml-with day_x> Here you are in the context of day_x, which is in the context of month_x, which is in the context of year_x, which is in the context of however you called this bit of DTML. Think of <dtml-with> as a tool to move around the object system and applying contexts. </dtml-with> </dtml-with> </dtml-with>
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!).
On the security tab for your method, only give users with the writer role permission to 'View' 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.).
So is it every single time or work on one page doesn't work on another? This paragraph is confusing. There is allways an AUTHENTICATED_USER object, if the user is not validated, the user object is 'Anonymous User'.
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?
(in the context of the folder containing the image) <dtml-var image> or <dtml-with image> <img src="<dtml-var absolute_url>"> </dtml-with>
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)
<dtml-in "objectValues('Image')"> <dtml-var id> </dtml-in> -Michel
participants (2)
-
Michel Pelletier -
Samu Mielonen