[Zope] Download counter

marc lindahl marc@bowery.com
Mon, 05 Nov 2001 12:21:21 -0500


> From: "e-Musty" <emusty@mailbox.hu>
>
> where fileDownload would be a Python script doing the stuff by checking the
> file's properties. If the file in question has a dwc attribute, it increases
> its value by one, if does not have, it creates the dwc property and sets its
> value to 1.


I'd discourage this - if you change something in the same object as the
media, then the object is appended again to the ZODB, which will cause
unneccessary bloat.  I'd either have your method update the catalog - you
could create a new index for the download count - or have separate
associated objects for each file.  Perhaps the FSCounter, which is a kind of
page counter, or ThreadSafeCounter.

> 
> The problem is that I cannot reach the object passed to the script. The
> question is, how to access that passed File object from Python. Can anyone
> help me?

Catalog searches don't return the object, but a kind of reference to it -
check the zope book for details.