[Zope] Download counter

e-Musty emusty@mailbox.hu
Mon, 5 Nov 2001 11:23:05 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_00EF_01C165EC.3D4E8D90
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Could anyone tell me how to implement a very single download counter?

I mean the followings:
Assume you have a folder named media with subfolders such as audio, video,
pic. All subfolderes might have another subfolders, e.g. mp3, wav, ra for
audio etc. All folder might have files, not just the lowest one.

The tricky thing I cannot figure out is how to write a script able to
maintain download counts.

What I've tried is that I've made the following change to my ZCatalog's
search result page:

<dtml-in aCatalogue>
  <a href="fileDownload('<dtml-var sequence-item>')">title_or_id</a><br>
</dtml-in>
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.

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?




------=_NextPart_000_00EF_01C165EC.3D4E8D90
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>Could =
anyone tell me=20
how to implement a very single download counter?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D577361510-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>I mean =
the=20
followings:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>Assume =
you have a=20
folder named media with subfolders such as audio, video, pic. All =
subfolderes=20
might have another subfolders, e.g. mp3, wav, ra for audio etc. All =
folder might=20
have files, not just the lowest one.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D577361510-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>The =
tricky thing I=20
cannot figure out is how to write a script&nbsp;able to maintain =
download=20
counts. </SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D577361510-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>What =
I've tried is=20
that I've made&nbsp;the following change to my&nbsp;ZCatalog's search =
result=20
page:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D577361510-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D577361510-05112001>&lt;dtml-in=20
aCatalogue&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D577361510-05112001>&nbsp; =
&lt;a=20
href=3D"fileDownload('&lt;dtml-var=20
sequence-item&gt;')"&gt;title_or_id&lt;/a&gt;&lt;br&gt;</SPAN></FONT></DI=
V>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D577361510-05112001>&lt;/dtml-in&gt;</SPAN></FONT></DIV>
<DIV class=3DSection1>
<P class=3DMsoNormal><SPAN class=3D577361510-05112001><FONT face=3DArial =
size=3D2>where=20
fileDownload would be a Python script doing the stuff by checking the =
file's=20
properties. If the file in question has a dwc attribute, it increases =
its value=20
by one, if does not have, it creates the dwc property and sets its value =
to=20
1.</FONT></SPAN></P>
<P class=3DMsoNormal><SPAN class=3D577361510-05112001><FONT face=3DArial =
size=3D2>The=20
problem is that I cannot reach the object passed to the script. The =
question is,=20
how to access that passed File object from Python. Can anyone help=20
me?</FONT></SPAN></P>
<P class=3DMsoNormal><SPAN class=3D577361510-05112001><FONT face=3DArial =

size=3D2></FONT></SPAN>&nbsp;</P></DIV></BODY></HTML>

------=_NextPart_000_00EF_01C165EC.3D4E8D90--