[Zope] How do I get the size of an item ?

Dieter Maurer dieter@handshake.de
Fri, 12 Jan 2001 23:58:52 +0100 (CET)


Dimitris Andrakakis writes:
 >    <dtml-var "_.get_size(_['<dtml-var "path[11:]">'])">
This is an FAQ (as you can imagine).

The list has a searchable archive, where you can find anwsers
to FAQ's.
I think, you will also find a compiled FAQ list via the
Zope documentation portal (zdp.zope.org).

This time, still , I will answer your question:

  if you would like to use "<dtml-var ...>" inside
  a Python expression, you can simply omit it
  (just use the "...") in most cases.
  It is more safe, however, to use "_[...]" instead,
  as this gives the same result.

  In your case (I suppose "path" is a string giving the filename
  (without path component) that can access the file from the
  current context!),
  you could probably use:
      <dtml-var "_.get_size(_[path[11:]])">

  If "path[11:]" contains pathname component, you probably
  will need to use "restrictedTraverse" (--> Online API reference).


Dieter