[Zope] Multiple DTML-questions

Michel Pelletier michel@digicool.com
Thu, 14 Oct 1999 16:56:58 -0400


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