[ZPT] Re: tal:condition question for TALES

Tonico Strasser contact_tonico at yahoo.de
Sat Sep 17 10:08:40 EDT 2005


Kim Groves schrieb:
> Hi,
> 
> Is it possible to use the existence of a file on the webserver as a
> condition in a TALES expression?
> 
> I have read many pages on Zope/TAL/TALES and they seem to indicate that it
> is, however none of the offered syntaxes seem to operate correctly.
> 
> Here is the scenario:
> 
> We have a directory on the webserver: /information
> which contains a set of pdf documents. The application is a cart, eg
> webshop.
> The products on the site may or may not have an associated pdf file. The
> name of the pdf is the same as the Product Id.
> eg:
>   <tr><td colspan=4><a target="" href="" tal:define="pdf_path
> string:/information/${product/pid}.pdf"
> tal:condition="exists:pdf_path" tal:attributes="href pdf_path; target
> pdf_path">Information Sheet</a></td></tr>
> 

I would write something like:

<a tal:define="fname string:${product/pid}.pdf;
                folder here/information"
    tal:condition="exists: folder/?fname"
    tal:attributes="href folder/?fname/absolute_url"
    target="_blank">
   Information Sheet
</a>

(I don't understand why you want to have the url in target attribute).

HTH
Tonico



More information about the ZPT mailing list