[Zope-CMF] How to check if an object exists?

seb bacon seb@jamkit.com
Fri, 12 Oct 2001 12:55:44 +0100


* Josef Albert Meile <jmeile@hotmail.com> [011012 11:59]:
> How can I know if an object (ie: a picture) exists?


> <dtml-if "REQUEST.resolve_url
> ('http://localhost:8080/MainPortal/myObjects/test')">
>   This resource exist
> <dtml-else>
>   This resource doesn't exist.
> </dtml-if>

resolve_url raises the same error that a normal HTTP request would,
e.g. NotFound, so you could do the following, for example:

 <dtml-try>
    <dtml-call "REQUEST.resolve_url
      ('http://localhost:8080/MainPortal/myObjects/test')">
    Supah.
 <dtml-except NotFound>
    Oh dear.
 </dtml-try>

seb