URL based access (was: [Zope] <dtml-if> question)

Dieter Maurer dieter@handshake.de
Thu, 22 Feb 2001 21:40:34 +0100 (CET)


Hans de Wit writes:
 > ....
 >              <dtml-let foto="'/Cis/fotos/afoto.jpg'">
 > 
 >              <dtml-if expr="_.getitem('foto')">
Keep in mind:

  You cannot use URL-strings to access objects, neither as
  DTML name nor as parameter to "getitem"!
  In both contexts, they will be interpreted as an atomic
  name.

  Whenever you want to access an object through an URL,
  you will use "restrictedTraverse" (if the URL
  describes a physical path) or "REQUEST.resolve_url"
  (for virtual URL's).

With these remarks, you can use:

     <dtml-if "_.hasattr(restrictedTraverse('/Cis/fotos'),'afoto.jpg')">


Dieter