Šī revīzija ir iekļauta:
Davide Alberani 2015-03-30 21:39:12 +02:00
vecāks 4fa42a677a
revīzija 8e40534a76
2 mainīti faili ar 18 papildinājumiem un 19 dzēšanām

Parādīt failu

@ -18,9 +18,6 @@ limitations under the License.
"""
import os
import json
import utils
import datetime
import tornado.httpserver
import tornado.ioloop
@ -29,20 +26,10 @@ from tornado.options import define, options
import tornado.web
from tornado import gen, escape
import utils
import backend
class ImprovedEncoder(json.JSONEncoder):
"""Enhance the default JSON encoder to serialize datetime objects."""
def default(self, o):
if isinstance(o, (datetime.datetime, datetime.date,
datetime.time, datetime.timedelta)):
return str(o)
return json.JSONEncoder.default(self, o)
json._default_encoder = ImprovedEncoder()
class BaseHandler(tornado.web.RequestHandler):
"""Base class for request handlers."""
def initialize(self, **kwargs):
@ -110,11 +97,8 @@ class EventsHandler(CollectionHandler):
collection = 'events'
class ImportPersonsHandler(BaseHandler):
pass
class EbCSVImportPersonsHandler(ImportPersonsHandler):
class EbCSVImportPersonsHandler(BaseHandler):
"""Importer for CSV files exported from eventbrite."""
csvRemap = {
'Nome evento': 'event_title',
'ID evento': 'event_id',

Parādīt failu

@ -17,8 +17,11 @@ limitations under the License.
"""
import csv
import json
import datetime
import StringIO
def csvParse(csvStr, remap=None, merge=None):
"""Parse a CSV file, optionally renaming the columns and merging other information.
@ -66,3 +69,15 @@ def csvParse(csvStr, remap=None, merge=None):
fd.close()
return reply, results
class ImprovedEncoder(json.JSONEncoder):
"""Enhance the default JSON encoder to serialize datetime objects."""
def default(self, o):
if isinstance(o, (datetime.datetime, datetime.date,
datetime.time, datetime.timedelta)):
return str(o)
return json.JSONEncoder.default(self, o)
# Inject our class as the default encoder.
json._default_encoder = ImprovedEncoder()