source: WAeUP_SRP/trunk/skins/waeup_pins/pin_statistics.py @ 8315

Last change on this file since 8315 was 5657, checked in by Henrik Bettermann, 14 years ago

Retrieve detailed information about pin batches.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1## Script (Python) "pin_statistics"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: pin_statistics.py 5657 2011-01-24 16:24:16Z henrik $
11request = context.REQUEST
12setheader = request.RESPONSE.setHeader
13fields = ("id",
14          "date",
15          "used",
16          "total",
17          "cost",
18          )
19
20lines = []
21lines.append(','.join(fields))
22format = '"%(' + ')s","%('.join(fields) + ')s"'               
23
24batches = []
25for id, object in context.objectItems():
26    batch = {}
27    batch['id'] = id
28    batch['date'] = object.creation_date.strftime("%d/%m/%y")
29    batch_doc = object.getContent()
30    batch['used'] = batch_doc.getNumberOfUsedPins()
31    batch['total'] = batch_doc.no_of_pins
32    batch['cost'] = batch_doc.cost
33    lines.append(format % batch)
34
35setheader('Content-type','text/semicolon-seperated-values')
36setheader('Content-Disposition:', 'attachment; filename="PinStatistics.csv"')
37setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
38setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
39setheader('Cache-Control', 'post-check=0,pre-check=0')
40return '\n'.join(lines)
41
Note: See TracBrowser for help on using the repository browser.