[triangle-zpug] Quick help w/a python statement

Stephan Altmueller stephan_altmueller at unc.edu
Wed Oct 21 16:34:54 UTC 2009


Hi Stephanie,

Depending on where this template code executes (Zope3 view or a page
template in a skin layer and also persmissions) the following might work:

  tal:condition="context/execsummlink/get_size"

or try

  tal:condition="python: context.getExecsummlink().get_size()

There are a million ways to do the same thing in Plone, I am sure there
are 5 other way ;-)

If you can, it would be a good idea to turn this in to a Zope 3 view,
then you can stick this kind of logic into a pure python function which
is much easier to debug.

Hope this helps,

     -- Stephan

Stephanie Thirolle wrote:
> Hey All,
>    I'm a relative python newbie and the following is driving me
> crazy.  If anyone has ANY suggestions, I'd be most grateful.
>
> I've got a FileField called 'execsummlink'  and I want to test if the
> field contains a file (or was left blank).  I've tried the following,
> but no matter what I do, I get a 'true' result regardless of whether
> the field contains anything:
>
> tal:condition="execsummlink"
> tal:condition="python: len(execsummlink) > 0"
> tal:condition="python: exists('here/execsummlink')"
> tal:condition="python: hasattr(here, 'execsummlink')"
> tal:condition="python: getattr(here, 'execsummlink')"
>
> ALL of these work with other field types (Image, string, text, etc) --
> any ideas why they won't work with a file field and what will???
>
> Thanks SO much for your time.
>
> Cheers!
> Stephanie
>


-- 
-------------------------------------------------
OASIS welcomes your feedback:   http://oasis.unc.edu/client-feedback

Stephan Altmueller
Applications Analyst, Enterprise Applications
Office of Arts and Sciences Information Services
University of North Carolina at Chapel Hill
CB 3056, 06 Howell Hall
Chapel Hill, NC 27599-3056 
919.448.5936 (direct line)
stephan_altmueller at unc.edu 
AIM: oasisaltmuell
http://oasis.unc.edu/people/altmuell




More information about the triangle-zpug mailing list