Re: Trying to work on a feature.

From: Joao De Almeida Pereira <jdealmeidapereira(at)pivotal(dot)io>
To: Rahul Soshte <rahulsoshte360(at)gmail(dot)com>
Cc: pgadmin-hackers(at)postgresql(dot)org
Subject: Re: Trying to work on a feature.
Date: 2018-03-26 19:01:37
Message-ID: CAE+jjakJK78KFFVmCkyBARHx=+CUbo41UtxGATk-1Yvmt-ctvg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hello Rahul,

This issues looks like it is located in the file
pgadmin/tools/sqleditor/__init__.py in the function save_file
Maybe around the code:

# generate full path of file
file_path = unquote(file_data['file_name'])
if hasattr(str, 'decode'):
file_path = unquote(
file_data['file_name']
).encode('utf-8').decode('utf-8')

Sorry if this seams obvious, but we would advise you to:
1 - Extract the function content of save_file to it's own file, something
like pgadmin/tools/sqleditor/utils/save_query_to_file.py
2 - Leave in the__init__.py file a shell function like

@blueprint.route('/save_file/', methods=["PUT", "POST"], endpoint='save_file')
@login_required
def save_file():
"""
This function retrieves file_name and data from request.
and then save the data to the file
"""
if request.data:
file_data = json.loads(request.data, encoding='utf-8')

save_query_to_file = SaveQueryToFile()
save_query_to_file.execute(file_data)

return make_json_response(
data={
'status': True,
}
)

3 - Create some tests around the current behavior of the function, similar
to the ones you can find in pgadmin/tools/sqleditor/utils/tests/*
4 - Create some tests to ensure if no extension is provided that it would
add a default one and implement this new behavior

And you should be set to go

Thanks
Victoria & Joao

On Mon, Mar 26, 2018 at 2:29 PM Rahul Soshte <rahulsoshte360(at)gmail(dot)com>
wrote:

> I am new to the codebase of pgAdmin4 and I am trying to work on this
> Feature.
>
> https://redmine.postgresql.org/issues/1998
>
> which appends .sql to files when using the feature "Save" or "Save As"
>
> Which files or folders I should be mostly grasping or looking at ?
>
>
>

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Robert Eckhardt 2018-03-26 20:26:18 Re: [pgAdmin4][RM#3055] Allow user to sort the data in View data mode
Previous Message Joao De Almeida Pereira 2018-03-26 18:42:53 Re: [pgAdmin4][Patch]: RM #1978 - Add an option to allow user to disable alertifyjs and acitree animations