Changeset 10027
- Timestamp:
- 15 Mar 2013, 00:58:05 (12 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/setup.py
r9999 r10027 24 24 'reportlab', 25 25 'PIL', 26 'unicodecsv', 26 27 'zope.app.authentication', # BBB: During switch to grok 1.1 27 28 'zope.app.file', -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r9931 r10027 18 18 """ Viewing components for Kofa objects. 19 19 """ 20 import csv 20 # XXX: All csv ops should move to a dedicated module soon 21 import unicodecsv as csv 21 22 import grok 22 23 import os … … 1044 1045 # XXX: temporary solution to prevent users from 1045 1046 # uploading non-ascii files. 1046 for element in filecontent:1047 try:1048 if ord(element) > 128:1049 self.flash(_(1050 "Only ASCII files are allowed. "1051 "Your file contains non-ASCII characters."))1052 logger.info('%s - non-ascii file uploaded: %s' %1053 (ob_class, target))1054 return1055 except TypeError:1056 self.flash(_(1057 "Only ASCII files are allowed. "1058 "Your file contains non-ASCII characters."))1059 logger.info('%s - non-ascii file uploaded: %s' %1060 (ob_class, target))1061 return1047 #for element in filecontent: 1048 # try: 1049 # if ord(element) > 128: 1050 # self.flash(_( 1051 # "Only ASCII files are allowed. " 1052 # "Your file contains non-ASCII characters.")) 1053 # logger.info('%s - non-ascii file uploaded: %s' % 1054 # (ob_class, target)) 1055 # return 1056 # except TypeError: 1057 # self.flash(_( 1058 # "Only ASCII files are allowed. " 1059 # "Your file contains non-ASCII characters.")) 1060 # logger.info('%s - non-ascii file uploaded: %s' % 1061 # (ob_class, target)) 1062 # return 1062 1063 1063 1064 open(target, 'wb').write(filecontent) -
main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py
r9823 r10027 22 22 """ 23 23 import grok 24 import csv25 24 import datetime 26 25 import os … … 28 27 import tempfile 29 28 import time 29 import unicodecsv 30 30 import zc.async.interfaces 31 31 from cStringIO import StringIO … … 142 142 """ 143 143 result = dict() 144 reader = csv.reader(open(path, 'rb'))144 reader = unicodecsv.reader(open(path, 'rb')) 145 145 raw_header = reader.next() 146 146 for num, field in enumerate(headerfields): … … 279 279 self.checkHeaders(headerfields, mode) 280 280 mapping = self.getMapping(path, headerfields, mode) 281 reader = csv.DictReader(open(path, 'rb'))281 reader = unicodecsv.DictReader(open(path, 'rb')) 282 282 283 283 temp_dir = tempfile.mkdtemp() … … 288 288 failed_headers = mapping.values() 289 289 failed_headers.append('--ERRORS--') 290 failed_writer = csv.DictWriter(open(failed_path, 'wb'),291 failed_headers)290 failed_writer = unicodecsv.DictWriter(open(failed_path, 'wb'), 291 failed_headers) 292 292 os.chmod(failed_path, 0664) 293 293 failed_writer.writerow(dict([(x,x) for x in failed_headers])) … … 295 295 finished_path = os.path.join(temp_dir, "%s.finished%s" % (base, ext)) 296 296 finished_headers = mapping.values() 297 finished_writer = csv.DictWriter(open(finished_path, 'wb'),298 finished_headers)297 finished_writer = unicodecsv.DictWriter(open(finished_path, 'wb'), 298 finished_headers) 299 299 os.chmod(finished_path, 0664) 300 300 finished_writer.writerow(dict([(x,x) for x in finished_headers])) … … 398 398 """ 399 399 outfile = StringIO() 400 writer = csv.DictWriter(outfile, self.available_fields)400 writer = unicodecsv.DictWriter(outfile, self.available_fields) 401 401 writer.writerow( 402 402 dict(zip(self.available_fields, self.available_fields))) # header … … 455 455 else: 456 456 outfile = open(filepath, 'wb') 457 writer = csv.DictWriter(outfile, self.fields)457 writer = unicodecsv.DictWriter(outfile, self.fields) 458 458 writer.writerow(dict(zip(self.fields, self.fields))) # header 459 459 return writer, outfile
Note: See TracChangeset for help on using the changeset viewer.