def GET(self, resource, context): app = resource.parent for form in app.get_forms(): state = form.get_value('form_state') if state != 'private': break else: return context.come_back(ERR_NO_DATA) format = context.query['format'] if format == 'xls': writer_cls = XLSWriter else: writer_cls = ODSWriter name = MSG(u"{title} Data").gettext(title=resource.get_title()) writer = writer_cls(name) schema = resource.get_schema() # Main header header = [ title.gettext() for title in (MSG(u"Form"), MSG(u"First Name"), MSG(u"Last Name"), MSG(u"E-mail"), MSG(u"State")) ] for name in sorted(schema): header.append(name.replace('_', '')) try: writer.add_row(header, is_header=True) except Exception, exception: return context.come_back(ERROR(unicode(exception)))