MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / get_tool_data

Function get_tool_data

web/pgadmin/settings/__init__.py:393–441  ·  view source on GitHub ↗
(trans_id)

Source from the content-addressed store, hash-verified

391 methods=["GET"], endpoint='get_tool_data')
392@pga_login_required
393def get_tool_data(trans_id):
394 fernet = Fernet(current_app.config['SECRET_KEY'].encode())
395 result = db.session \
396 .query(ApplicationState) \
397 .filter(ApplicationState.uid == current_user.id,
398 ApplicationState.id == trans_id) \
399 .first()
400
401 if result:
402 connection_info = result.connection_info
403 tool_data = fernet.decrypt(result.tool_data).decode()
404
405 if (connection_info and 'open_file_name' in connection_info and
406 connection_info['open_file_name']):
407 file_path = (
408 get_complete_file_path(connection_info['open_file_name']))
409 file_deleted = False if file_path else True
410 connection_info['file_deleted'] = file_deleted
411
412 if (not file_deleted and connection_info['is_editor_dirty'] and
413 'last_saved_file_hash' in connection_info and
414 connection_info['last_saved_file_hash']):
415 connection_info['external_file_changes'] = \
416 check_external_file_changes(
417 file_path, connection_info['last_saved_file_hash'])
418
419 if not (file_deleted or connection_info['is_editor_dirty']):
420 # Send tool data only if file is deleted or edited
421 tool_data = None
422
423 return make_json_response(
424 data={
425 'status': True,
426 'msg': '',
427 'result': {
428 'connection_info': connection_info,
429 'tool_data': tool_data,
430 'id': result.id
431 }
432 }
433 )
434 else:
435 return (
436 make_json_response(
437 success=0,
438 errormsg=gettext(
439 'There is no saved content available for this tab.'),
440 status=404
441 ))
442
443
444@blueprint.route(

Callers

nothing calls this directly

Calls 7

get_complete_file_pathFunction · 0.90
make_json_responseFunction · 0.90
gettextFunction · 0.85
filterMethod · 0.80
decodeMethod · 0.80
firstMethod · 0.65

Tested by

no test coverage detected