MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / save_application_state

Function save_application_state

web/pgadmin/settings/__init__.py:289–321  ·  view source on GitHub ↗

Expose an api to save the application state which stores the data from query tool, ERD, schema-diff, psql

()

Source from the content-addressed store, hash-verified

287)
288@pga_login_required
289def save_application_state():
290 """
291 Expose an api to save the application state which stores the data from
292 query tool, ERD, schema-diff, psql
293 """
294 data = json.loads(request.data)
295 trans_id = data['trans_id']
296 fernet = Fernet(current_app.config['SECRET_KEY'].encode())
297 tool_data = fernet.encrypt(json.dumps(data['tool_data']).encode())
298 connection_info = data['connection_info'] \
299 if 'connection_info' in data else None
300 if (connection_info and 'open_file_name' in connection_info and
301 connection_info['open_file_name']):
302 file_path = get_complete_file_path(connection_info['open_file_name'])
303 connection_info['last_saved_file_hash'] = (
304 get_last_saved_file_hash(file_path, trans_id))
305
306 try:
307 data_entry = ApplicationState(
308 uid=current_user.id, id=trans_id,connection_info=connection_info,
309 tool_data=tool_data)
310
311 db.session.merge(data_entry)
312 db.session.commit()
313 except Exception as e:
314 print(e)
315 db.session.rollback()
316
317 return make_json_response(
318 data={
319 'status': True,
320 'msg': 'Success',
321 })
322
323
324def get_last_saved_file_hash(file_path, trans_id):

Callers

nothing calls this directly

Calls 4

get_complete_file_pathFunction · 0.90
ApplicationStateClass · 0.90
make_json_responseFunction · 0.90
get_last_saved_file_hashFunction · 0.85

Tested by

no test coverage detected