source: products/qTopic/branches/plone2.1/skins/qtopic/export_csv.py @ 1

Last change on this file since 1 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 925 bytes
Line 
1## Script (Python) "isATCTbased"
2##title=Formats the history diff
3##bind container=container
4##bind context=context
5##bind namespace=
6##bind script=script
7##bind subpath=traverse_subpath
8##parameters=download=0,fields=None,show_header=1
9if download:
10    context.REQUEST.RESPONSE.setHeader('Content-Type', 'plain/text')
11    context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'attachment; filename="%s.csv"'% context.getId())
12
13res = context.queryCatalog()
14fields = fields or context.getCustomViewFields()
15
16if hasattr(context, 'getDelimiter'):
17    delimiter = context.getDelimiter() or ';'
18else:
19    delimiter = ','
20
21if hasattr(context, 'getShowHeader'):
22    if show_header and context.getShowHeader():
23        print delimiter.join(fields)
24else:
25    if show_header:
26        print delimiter.join(fields)
27
28
29for r in res:
30   print delimiter.join([test(getattr(r, f, ''),getattr(r, f, ''),'') for f in fields])
31return printed
Note: See TracBrowser for help on using the repository browser.