[Zope] From ColdFusion to Zope: help with <dtml-if>?

Chris McDonough chrism@digicool.com
Wed, 18 Jul 2001 19:14:00 -0400


This is actually more a Python question, as Zope doesn't deal directly
with files in any way.

A function which checks for the existence of a file follows:

def fileExists(path):
    import os
    return os.path.exists(path) and os.path.isfile(path)

You'd use this as an external method in Zope like so:

   <dtml-if "fileExists('/home/chrism/afile')">do soemthing
   <dtml-else>do something else
   </dtml-if>

In her case, it'd be:

   <dtml-if "fileExists(varfile)">show current month's file
   <dtml-else>show last month's file
   </dtml-if>

HTH,

- C


Bob Campbell wrote:
> 
> Hi,
> One of our business line developers is used to working with ColdFusion and
> is struggling, as we all are-:), with Zope. We are literally surrounded with
> piles of documents, e-books, and e-mail messages "explaining" the different
> aspects of Zope. We are slowly "getting it" and liking it... However...
> 
> The developer (and myself) have been trying to figure this out for two days
> and push is now coming to shove and I'm hoping the list can help.
> 
> I asked her write down in plain English what she is trying to accomplish and
> I would post it and see if anyone has a solution or solid direction to
> pursue.
> The  system she developed  publishes hundreds of multipage reports using MS
> Access and Acrobat (pdf). Access holds the links to every report, they are
> dated and published throughout a two week cycle. The reports themselves
> reside on numbered folders on a local drive (e:) In ColdFusion she would do
> something like, IF Fileexists (001delingprt) then .....and so on through the
> reports...
> Here is what she wrote
> ___________________________________________________________________________
> 
> Ok, here it is in plain English...
> 
> I need to determine if a certain file exists.  The filename is located in a
> certain variable.  If it does exist do something, else do something else.
> 
> For example:
> Say the file is called e:\test.pdf.  This path exists in a variable called
> vartest
> 
> If vartest exists then show the current month's file else show last month's
> file.
> 
> Hope there's an answer.
> 
> Sheree Beaudette, AVP
> Applications Support Analyst
> Banknorth Group, Commercial Services
> sbeaudette@banknorth.com
> 
> Thanks,
> Bob Campbell
> Business Line Intranet Development
> Banknorth Group
> 207-761-8595
> bcampbell@banknorth.com
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> 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 )