Skip to content

Commit

Permalink
Added default export in the export config, updated export logic usage…
Browse files Browse the repository at this point in the history
… key
  • Loading branch information
punith300i committed Jun 3, 2023
1 parent 36ffa26 commit 79bdb74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion sand/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
# "default": "mtab",
},
"exports": {
"drepr": "sand.extensions.export.drepr.main.DreprExport"
"drepr": "sand.extensions.export.drepr.main.DreprExport",
"default": "sand.extensions.export.drepr.main.DreprExport"
}
}
12 changes: 6 additions & 6 deletions sand/controllers/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ class UpdateColumnLinksInput:
GetExportCache = threading.local()


def get_exports(name) -> IExport:
def get_export(name) -> IExport:
global GetExportCache

if not hasattr(GetExportCache, "exports"):
GetExportCache.exports = {}
if not hasattr(GetExportCache, "export"):
GetExportCache.export = {}
export_config = SETTINGS["exports"]
constructor = export_config[name]
GetExportCache.exports[name] = import_func(constructor)()
GetExportCache.export[name] = import_func(constructor)()

return GetExportCache.exports[name]
return GetExportCache.export[name]


@table_bp.route(f"/{table_bp.name}/<id>/export-models", methods=["GET"])
Expand Down Expand Up @@ -139,7 +139,7 @@ def export_table_data(id: int):
rows: List[TableRow] = list(TableRow.select().where(TableRow.table == table))

# export the data using drepr library
content = get_exports('drepr').export_data(table, rows, sm.data, OutputFormat.TTL)
content = get_export('default').export_data(table, rows, sm.data, OutputFormat.TTL)
resp = make_response(content)
resp.headers["Content-Type"] = "text/ttl; charset=utf-8"
if request.args.get("attachment", "false") == "true":
Expand Down

0 comments on commit 79bdb74

Please sign in to comment.