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
|
# Check content type. It will probably be either XML or JSON
|
||||||
try:
|
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)
|
etree.fromstring(content)
|
||||||
response.content_type = 'application/xml'
|
response.content_type = 'application/xml'
|
||||||
except XMLSyntaxError:
|
except XMLSyntaxError:
|
||||||
|
@ -262,8 +270,8 @@ class ViewController(BaseController):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
response.headers['Content-Length'] = len(obj['content'])
|
response.headers['Content-Length'] = len(content)
|
||||||
return obj['content']
|
return content
|
||||||
except NotFound:
|
except NotFound:
|
||||||
abort(404,_('Harvest object not found'))
|
abort(404,_('Harvest object not found'))
|
||||||
except NotAuthorized,e:
|
except NotAuthorized,e:
|
||||||
|
|
|
@ -44,10 +44,13 @@ def harvest_object_dictize(obj, context):
|
||||||
out['package'] = obj.package.id
|
out['package'] = obj.package.id
|
||||||
|
|
||||||
out['errors'] = []
|
out['errors'] = []
|
||||||
|
|
||||||
for error in obj.errors:
|
for error in obj.errors:
|
||||||
out['errors'].append(error.as_dict())
|
out['errors'].append(error.as_dict())
|
||||||
|
|
||||||
|
out['extras'] = {}
|
||||||
|
for extra in obj.extras:
|
||||||
|
out['extras'][extra.key] = extra.value
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def _get_source_status(source, context):
|
def _get_source_status(source, context):
|
||||||
|
|
Loading…
Reference in New Issue