Return original document if present when requesting an object
This commit is contained in:
parent
820443d58f
commit
54ff0526bb
|
@ -252,7 +252,15 @@ class ViewController(BaseController):
|
|||
|
||||
# Check content type. It will probably be either XML or JSON
|
||||
try:
|
||||
content = re.sub('<\?xml(.*)\?>','', obj['content'])
|
||||
|
||||
if obj['content']:
|
||||
content = obj['content']
|
||||
elif 'original_document' in obj['extras']:
|
||||
content = obj['extras']['original_document']
|
||||
else:
|
||||
abort(404,_('No content found'))
|
||||
|
||||
content = re.sub('<\?xml(.*)\?>','',content)
|
||||
etree.fromstring(content)
|
||||
response.content_type = 'application/xml'
|
||||
except XMLSyntaxError:
|
||||
|
@ -262,8 +270,8 @@ class ViewController(BaseController):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
response.headers['Content-Length'] = len(obj['content'])
|
||||
return obj['content']
|
||||
response.headers['Content-Length'] = len(content)
|
||||
return content
|
||||
except NotFound:
|
||||
abort(404,_('Harvest object not found'))
|
||||
except NotAuthorized,e:
|
||||
|
|
|
@ -44,10 +44,13 @@ def harvest_object_dictize(obj, context):
|
|||
out['package'] = obj.package.id
|
||||
|
||||
out['errors'] = []
|
||||
|
||||
for error in obj.errors:
|
||||
out['errors'].append(error.as_dict())
|
||||
|
||||
out['extras'] = {}
|
||||
for extra in obj.extras:
|
||||
out['extras'][extra.key] = extra.value
|
||||
|
||||
return out
|
||||
|
||||
def _get_source_status(source, context):
|
||||
|
|
Loading…
Reference in New Issue