remove inefficient json.loads(json.dumps()) in listing API
This commit is contained in:
parent
30c0e72436
commit
d24711a7f0
|
@ -865,7 +865,7 @@ class FormPage(Directory):
|
|||
selected_filter, user=user, query=query, criterias=criterias,
|
||||
order_by=order_by)
|
||||
if get_request().form.get('full') == 'on':
|
||||
output = [json.loads(filled.export_to_json(include_files=False)) for filled in items]
|
||||
output = [filled.get_json_export_dict(include_files=False) for filled in items]
|
||||
else:
|
||||
output = [{'id': filled.id,
|
||||
'url': filled.get_url(),
|
||||
|
|
|
@ -545,7 +545,7 @@ class FormData(StorableObject):
|
|||
evo.parts = None
|
||||
self.store()
|
||||
|
||||
def export_to_json(self, include_files=True):
|
||||
def get_json_export_dict(self, include_files=True):
|
||||
data = {}
|
||||
data['id'] = '%s/%s' % (self.formdef.url_name, self.id)
|
||||
data['display_id'] = self.get_display_id()
|
||||
|
@ -581,6 +581,10 @@ class FormData(StorableObject):
|
|||
if self.workflow_data:
|
||||
data['workflow']['data'] = self.workflow_data
|
||||
|
||||
return data
|
||||
|
||||
def export_to_json(self, include_files=True):
|
||||
data = self.get_json_export_dict(include_files=include_files)
|
||||
return json.dumps(data,
|
||||
cls=qommon.misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
|
|
Loading…
Reference in New Issue