def tmpl_from_request(id, params): context = {} params, remcoll = handle_create_collection(params) validator = RecordValidator(params, remcoll) if validator.invalid_collections: return dict(invalid_collections=validator.invalid_collections) newid = params.get('newid') ok = True try: # FIXME - check csrf token record = validator.validate() tmpl = Template(newid, None, record) except ValidationError, e: context['error'] = e.errormsg ok = False orig_tmpl = get_or_404(Template, id) record = dict(inner_xml=params.get('inner_xml', None), collections=validator.collections, fieldnums=orig_tmpl.record.fieldnums, walkfields=orig_tmpl.record.walkfields, ) tmpl = dict(record=record, id=newid, )
def record_from_request(id): params = cherrypy.request.params context = {} params, remcoll = handle_create_collection(params) validator = RecordValidator(params, remcoll) if validator.invalid_collections: return dict(invalid_collections=validator.invalid_collections) ok = True try: # FIXME - check csrf token record = validator.validate() except ValidationError, e: context['error'] = e.errormsg ok = False orig_record = get_or_404(Record, id) record = dict(inner_xml=params.get('inner_xml', None), collections=validator.collections, fieldnums=orig_record.fieldnums, walkfields=orig_record.walkfields, id=id, )