I made a DTML method which works, but doesn't do it
recursively. I'll try external methods.

Thanks..

<dtml-if fname>
 <dtml-try "_.getitem(_['fname'],1)">
   <dtml-with "_.getitem(_['fname'],1)">
    <dtml-var title>
    <dtml-unless "meta_type=='Folder'">
      Item exists, but not a folder
    </dtml-unless>
   </dtml-with>
 <dtml-except>
   Folder not found
   <dtml-if ftitle>
    <dtml-try>
       <dtml-call "manage_addFolder(_['fname'],_['ftitle'])">
        Folder Created
    <dtml-except>
       Folder could not be created
    </dtml-try>
   <dtml-else>
    <dtml-try>
      <dtml-call "manage_addFolder(_['fname'],_['fname'])">
       Folder Created
    <dtml-except>
       Folder could not be created
    </dtml-try>
   </dtml-if>
 </dtml-try>
</dtml-if fname>
----- Original Message -----
From: Dieter Maurer <[EMAIL PROTECTED]>
To: Satheesh Babu <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, July 26, 2000 3:27 PM
Subject: Need for "aq_base" in DTML (was: Re: [Zope] Dumb DTML question -
existance check of an object)


> Satheesh Babu writes:
>  > I have a URL, say, /sub1/sub2. How do I check in DTML
>  > whether
>  >   1. folder sub1 exists or not
>  >   2. If not, create it.
>  >   3. folder sub2 exists under sub1
>  >   4. If not, create it.
> It is easy, if you are a bit sloppy.
>
>  * Access to "/": "PARENTS[-1]"
>  * Existence check: "_.hasattr(object,what)"
>      NOTE, that this is the sloppy part.
>
>       - "_.hasattr" will return true, if "object" has
>         attribute "what" (that is what we want)
> *OR* when it has acquired such an attribute
> (we do *NOT* want that here).
>
> What we would need is a DTML accessible version
> of "aq_base". This is trivially handled by
> an external method.
>
>       - it returns true, when there is such an attribute.
>         This may not be a folder.
>
> You can check "meta_type" to see, it is indeed a folder.
>
>  * creation: "manage_addFolder"
>      look in the ZDP's (http:zdp.zope.org) object reference
>      for the function's signature.
>
>      I think, this info is available in the Zope 2.2 help system, too.
>
>
> Dieter
>


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to