Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0XR6-0005hp-Jj for pgadmin-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 19:05:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0XR5-00043j-Fk for pgadmin-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 19:05:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0XNT-0007MK-NA for pgadmin-hackers@lists.postgresql.org; Mon, 26 Mar 2018 19:01:55 +0000 Received: from mail-io0-x22c.google.com ([2607:f8b0:4001:c06::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0XNO-0006e1-D7 for pgadmin-hackers@postgresql.org; Mon, 26 Mar 2018 19:01:52 +0000 Received: by mail-io0-x22c.google.com with SMTP id d7so9180417ioc.11 for ; Mon, 26 Mar 2018 12:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pivotal-io.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BSpHdQdjjsLPE4Y5PoxzyNDoXkcITrS51cG5Ql+CIX0=; b=arbBxdX/CiVHHhoqCq0rXvwC2X3e9Q/f91H2w7iEbzeen6gMtOHYMQqLp3Loxu6IVQ hnrPe5mVGWFL+QpreyF+kuFNSlKkFoM3Qk57fXEKFrOsggbHXhcAg+nfWlM9htsuZLUv Ag0Vy/l3+YA2Zz1E5dCdNfRkhxJtSLFIxTd58tik8zIzPJXwx6Hs32uN8Wj3kdQnzVCD 6XZC5VGNOga9dB2wT8h0K+0pYeYUG698JriRkjtxW+gOLkEWkMGvmSnwcZs8IZ3qqSkQ 4IlPxDUqcaqS2nZu8WlCU5bvmw03ZmnqHIrgurOwk5sXXwRf3TGNfxq8pMY8ZsekGdly ue5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BSpHdQdjjsLPE4Y5PoxzyNDoXkcITrS51cG5Ql+CIX0=; b=mBXHgcynsOjcMDvY3LwjWut8ictOTGfxLFs2tWtSJxEQJ63hplVRIH03YUFvBQcWOy 6F2q5tlkuA6qJzc+NZiAE8gZJesMNBvNTtJlTPGKtONvlEGWRsROInRlZu0Xl7oFvZma uTQVqwlIppJd928Z/cHkJlz4L8GSvfy91Lqz0edXDLfm9xW5jwW6Fp1T04ko7Tcy2CwR JJrADZwavLDA5gdAqsZ5n4s5JzBGFRm44Q7CNyCMVsg39k634AL7y08TX34ti/Ta6Rjc DfcH2ph2qV93lsllbFG4+ul23OecBQJIjsJZyaJ4gaJtPNY3vqGVmUZRr5PFSh/4aH57 p3uQ== X-Gm-Message-State: AElRT7FBC8OgC5CnHp1LBew+4AeZJseMV4Q9PqCQpTuqPIN+fDV1ZnTn ku6zzCJ+N83a3Ua/z27rsFgjSZ0F8Iq/IjvtoIhksw== X-Google-Smtp-Source: AG47ELuZyP1KoWlYC5BAgfKNTP/KjFStz4W+FakJNclfpOIW0i9gMwaGVSqc0ZxHB4fVUspKO4k2tK4Re7Mt3dsbTQs= X-Received: by 10.107.55.9 with SMTP id e9mr42186796ioa.69.1522090908342; Mon, 26 Mar 2018 12:01:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Joao De Almeida Pereira Date: Mon, 26 Mar 2018 19:01:37 +0000 Message-ID: Subject: Re: Trying to work on a feature. To: Rahul Soshte Cc: pgadmin-hackers@postgresql.org Content-Type: multipart/alternative; boundary="001a114ab772e8a0f80568556773" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --001a114ab772e8a0f80568556773 Content-Type: text/plain; charset="UTF-8" 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 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 ? > > > --001a114ab772e8a0f80568556773 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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:
# gene=
rate full path of file
file_path =3D unquote(file_data['file_name'])
if has= attr(str, '= ;decode'):
file_path =3D unquote(
file_data['file_name']
).en= code('utf-8').decode(<= span style=3D"color:rgb(165,194,97)">'utf-8')
Sorry if this seams obvious, but we would advise you to:
1 - Ex= tract the function content of save_file to it's own file, something lik= e=C2=A0pgadmin/tools/sqleditor/utils/save_query_to_file.py
2 - Le= ave in the__init__.py file a shell function like=C2=A0
@blueprint.route('/sa=
ve_file/', methods=3D["PUT", "POST"], =
endpoint=3D'save_file'=
)
@login_required
def save_file():
"""
This function retrieves file_name and dat= a from request.
and then save the data to the file
"""
if request.data:
file_data =3D json= .loads(request.data, encoding=3D'utf-8')
=
save_query_to_= file =3D SaveQueryToFile()
save_query_to_file.execute(file_data)
=
return make_j= son_response(
= data=3D{
'sta= tus': True,
}
)
3 - Create some tests around the current behavior of the function, simila= r 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 woul= d add a default one and implement this new behavior

And you should be set to go

Thanks
Vic= toria & Joao

On Mon, Mar 26, 2018 at 2:29 PM Rahul Soshte <rahulsoshte360@gmail.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 file= s when using the feature "Save" or "Save As"
<= div>
Which files or folders I should be mostly grasping or looking= at ?


--001a114ab772e8a0f80568556773--