'Return the traffic data in CSV format for reports.'

@classmethod
def as_csv(cls, thing):

    import csv
    import cStringIO
    (start, end) = promote.get_traffic_dates(thing)
    history = cls.get_hourly_traffic(thing, start, end)
    out = cStringIO.StringIO()
    writer = csv.writer(out)
    writer.writerow((_('date    and    time    (UTC)'), _('impressions'), _('clicks'), _('click-through    rate    (%)')))
    for (date, datestr, values) in history:
        writer.writerow(((date,) + values))
    return out.getvalue()
