[Zope] total size of files in a folder

Cornelis J. de Brabander brabander@fsw.LeidenUniv.nl
Wed, 27 Feb 2002 13:51:35 +0100


I was not sure about your first dtml-let either, so I tried your code myself
and ended up with:

<dtml-call "REQUEST.set('total_size',0)">
<dtml-in "objectValues(['File'])">
 <dtml-call "REQUEST.set('total_size',total_size+size)">
 <dtml-var title_or_id><br>
 <dtml-if sequence-end>
  <dtml-var total_size>
 </dtml-if>
</dtml-in>

which works.
cb

> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Marcus Bergmann
> Sent: woensdag 27 februari 2002 13:23
> To: zope@zope.org
> Subject: Re: [Zope] total size of files in a folder
>
>
> "Cornelis J. de Brabander" wrote:
> >
> > Your total_size is initialized for each element of your
> objectValues list.
> > I would use "REQUEST.set('total_size'=total_size+size)"
> > cheers
> >
> > Cornelis J. de Brabander
> > >
>
> Thanks, but I dont understand what peace of my code I have to change.
> Try and error gave me no success.
>
> Marcus
>
> > >
> > > Hi,
> > >
> > > I want to get the total size of a folder. I do a loop over
> all files in
> > > the folder, but it gives me only the size of the last file in the
> > > folder:
> > >
> > > <dtml-let total_size="0">
> > >  <dtml-in "Files.objectValues()">     #Files is the name of my folder
> > >   <dtml-let total_size="total_size+size">
> > >    <dtml-if sequence-end>
> > >     <dtml-var total_size>
> > >    </dtml-if>
> > >   </dtml-let>
> > >  </dtml-in>
> > > </dtml-let>
> > >
> > > Alternatively, is there simply a variable I can lookup to get the size
> > > of the folder?
> > >
> > > Thank you,
> > > Marcus
>
> _______________________________________________
> 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 )
>