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

Function save

web/pgadmin/tools/grant_wizard/__init__.py:543–628  ·  view source on GitHub ↗

This function will apply the privileges to the selected Database Objects

(sid, did)

Source from the content-addressed store, hash-verified

541@pga_login_required
542@check_precondition
543def save(sid, did):
544 """
545 This function will apply the privileges to the selected
546 Database Objects
547 """
548 server_prop = server_info
549 data = get_req_data()
550
551 # Form db connection and we use conn to execute sql
552 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
553 conn = manager.connection(did=did)
554
555 acls = []
556 try:
557 acls = render_template(
558 "/".join([server_prop['template_path'], 'acl.json']),
559 )
560 acls = json.loads(acls)
561 except Exception as e:
562 current_app.logger.exception(e)
563
564 try:
565
566 # Parse privileges
567 data['priv'] = {}
568 parse_priv(data, acls, server_prop)
569 # Pass database objects and get SQL for privileges
570 # Pass database objects and get SQL for privileges
571 sql_data = ''
572 data_func = {'objects': data['objects'],
573 'priv': data['priv']['function']}
574 sql = render_template(
575 "/".join([server_prop['template_path'],
576 '/sql/grant_function.sql']),
577 data=data_func, conn=conn)
578 if sql and sql.strip('\n') != '':
579 sql_data += sql
580
581 data_seq = {'objects': data['objects'],
582 'priv': data['priv']['sequence']}
583 sql = render_template(
584 "/".join([server_prop['template_path'],
585 '/sql/grant_sequence.sql']),
586 data=data_seq, conn=conn)
587 if sql and sql.strip('\n') != '':
588 sql_data += sql
589
590 data_table = {'objects': data['objects'],
591 'priv': data['priv']['table']}
592 sql = render_template(
593 "/".join([server_prop['template_path'], '/sql/grant_table.sql']),
594 data=data_table, conn=conn)
595 if sql and sql.strip('\n') != '':
596 sql_data += sql
597
598 data_table = {'objects': data['objects'],
599 'priv': data['priv']['foreign_table']}
600 sql = render_template(

Callers

nothing calls this directly

Calls 9

get_driverFunction · 0.90
internal_server_errorFunction · 0.90
make_json_responseFunction · 0.90
get_req_dataFunction · 0.85
parse_privFunction · 0.85
connection_managerMethod · 0.80
connectionMethod · 0.80
joinMethod · 0.80
execute_dictMethod · 0.45

Tested by

no test coverage detected