annotate data/plugin/action/submitcsv.py @ 623:5f499a634857

FormSubmit: fix pep8, remove unused imports, ...
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Mar 2013 17:20:34 +0100
parents 12465aa315be
children bdebdc59b057
rev   line source
622
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - submitcsv Action
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 Store submited data into CSV file. CSV file is located
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 in standard MoinMoin attchment folder or defined in
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 targetpage CGI parameter.
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 @copyright: 2008 by Peter Bodi <petrdll@centrum.sk>
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 """
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
623
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
13 import os
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
14 import csv
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
15 import codecs
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
16 import cStringIO
622
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 from MoinMoin import config, wikiutil
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 from MoinMoin.Page import Page
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 from MoinMoin.action import AttachFile
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 from submitbase import SubmitBase
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23
623
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
24
622
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 def execute(pagename, request):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 submitcsv(pagename, request).render()
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27
623
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
28
622
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 class submitcsv(SubmitBase):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 def __init__(self, pagename, request):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 SubmitBase.__init__(self, pagename, request)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 self.delimiter = ';'
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 self.targetFile = ""
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 if(request.form.has_key("targetfile")):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 self.targetFile = request.form.get("targetfile")[0]
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 else:
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 self.targetFile = u"list.csv"
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 def sanitize(self):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 SubmitBase.sanitize(self)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 self.targetFile = wikiutil.clean_input(self.targetFile)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 def submit(self):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 SubmitBase.submit(self)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 request = self.request
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 pagename = self.targetpage
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 attachDir = AttachFile.getAttachDir(request, pagename, create=1)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 targetFile = self.targetFile
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 filePath = os.path.join(attachDir, targetFile).encode(config.charset)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 # save header
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 if not os.path.exists(filePath):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 fh = open(filePath, 'wb')
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 # Encoded Input to writer.writerow
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 writer = csv.writer(fh, delimiter=self.delimiter)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 writer.writerow(self.labels)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 # Decoded Input to writer.writerow
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 #writer = UnicodeWriter(fh, delimiter=self.delimiter)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 #writer.writerow(self.labels)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69 fh.close()
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 # save content
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 fh = open(filePath, 'ab')
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 # Encoded Input to writer.writerow
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 #writer = csv.writer(fh, delimiter=self.delimiter, quoting=csv.QUOTE_MINIMAL)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 #writer.writerow(self.values)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 # Decoded Input to writer.writerow
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79 writer = UnicodeWriter(fh, delimiter=self.delimiter, quoting=csv.QUOTE_MINIMAL)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 writer.writerow(self.values)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 fh.close()
623
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
83
5f499a634857 FormSubmit: fix pep8, remove unused imports, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
84
622
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 class UnicodeWriter:
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86 """
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 A CSV writer which will write rows to CSV file "f",
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 which is encoded in the given encoding.
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 """
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 # Redirect output to a queue
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93 self.queue = cStringIO.StringIO()
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94 self.writer = csv.writer(self.queue, dialect=dialect, **kwds)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95 self.stream = f
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 self.encoder = codecs.getincrementalencoder(encoding)()
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 def writerow(self, row):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99 self.writer.writerow([s.encode("utf-8") for s in row])
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100 # Fetch UTF-8 output from the queue ...
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
101 data = self.queue.getvalue()
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
102 data = data.decode("utf-8")
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
103 # ... and reencode it into the target encoding
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
104 data = self.encoder.encode(data)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
105 # write to the target stream
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
106 self.stream.write(data)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
107 # empty queue
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
108 self.queue.truncate(0)
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
109
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
110 def writerows(self, rows):
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
111 for row in rows:
12465aa315be add code from ActionMarket/FormSubmit (form_submit-1.7.tar.gz) - outdated code for moin 1.7/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
112 self.writerow(row)