[Zope] Problem with calling methods
Oliver Bleutgen
myzope@gmx.net
Thu, 12 Jun 2003 11:05:29 +0200
Nikel, Ernst-Dieter wrote:
> Hi everyone,
>
> I have the following problem:
>
> For example consider the code:
>
> <dtml-in "test.ba.objectValues()">
> <dtml-var id>
> </dtml-in>
>
> This gives the ids in the folder test/ba.
>
> My problem is that in my applcation I get the path like "test/ba" in the
> example through a REQUEST. The script
>
> <dtml-in "_[tt].ba.objectValues()">
> <dtml-var id>
> </dtml-in>
>
> works if the variable "tt" contains the value "test". But I don't have found
> a possibility to call the method if the given path (or better the relevant
> part of the path) contains more than one folder.
>
> The code
>
> <dtml-in "_[tt].objectValues()">
> <dtml-var id>
> </dtml-in>
>
> don't works if the variable "tt" contains "test.ba".
Take a look at restrictedTraverse() (search the online help).
Three other remarks:
- It's in general not a good idea to trust anything coming from the
client (the REQUEST) like you do. If you are using restrictedTravere for
instance, your code will possibly reveal contents of folders which you
don't want revealed if the user sends the right value for tt.
- If you just need the ids of your objects, better use objectIds instead
of objectValues, the former is much faster.
- If you need to use objectValues, don't use id to get the Ids of these
objects, use getId(), because not every object implements the id
attribute in the same way.
cheers,
oliuver