def handle(self, *app_labels, **options): from dockit.schema.loading import get_documents format = options.get('format','json') indent = options.get('indent',None) show_traceback = options.get('traceback', False) # Check that the serialization format exists; this is a shortcut to # avoid collating all the objects and _then_ failing. if format not in serializers.get_public_serializer_formats(): raise CommandError("Unknown serialization format: %s" % format) try: serializers.get_serializer(format) except KeyError: raise CommandError("Unknown serialization format: %s" % format) # Now collate the objects to be serialized. objects = [] excluded_documents = [] for document in get_documents(): if document in excluded_documents: continue if app_labels and document._meta.app_label not in app_labels: continue objects.extend(document.objects.all()) try: return serializers.serialize(format, objects, indent=indent) except Exception, e: if show_traceback: raise raise CommandError("Unable to serialize database: %s" % e)
def prep_data(data): prep_data = dockit_serializers.serialize('python', data) results = data_source.to_payload(data_source_key, prep_data, **options) return [results]
def dump(cls, objects, data_source, data_source_key, **options): data = dockit_serializers.serialize('python', objects) results = data_source.to_payload(data_source_key, data, **options) return {'data': [results]}