Обсуждение: [pgadmin-hackers] [pgAdmin4]: RM-1910 - Remember last used directory in the file manager
Hi,
Please find attached patch file which contains the fix of last used directory in file manager.
Now file manager will remember last used directory per user basis and will be store in SQLite database.
Do review it and let us know for comments.
Thanks,
Neel Patel
Вложения
Hi On Fri, Dec 9, 2016 at 10:23 AM, Neel Patel <neel.patel@enterprisedb.com> wrote: > Hi, > > Please find attached patch file which contains the fix of last used > directory in file manager. > Now file manager will remember last used directory per user basis and will > be store in SQLite database. > > Do review it and let us know for comments. To avoid an exception, I had to change the hunk at line 578 of file_manager/__init__.py to check for self.dir == None, e.g. dir = self.dir if self.dir is not None else '' if not dir.endswith('/'): dir += '/'; However, I then ran into a problem that if the directory that has been remembered no longer exists, I get an error message. I believe it should traverse back up the path to find the closest directory that is still present. Can you look at that please? -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hi Dave,
Please find attached patch file with the fix of below suggestion.
- If the directory that has been remembered no longer exists, then find closest parent directory to set last remembered directory.
Do review it and let us know for comments.
Thanks,
Neel Patel
On Fri, Dec 9, 2016 at 5:54 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
On Fri, Dec 9, 2016 at 10:23 AM, Neel Patel <neel.patel@enterprisedb.com> wrote:
> Hi,
>
> Please find attached patch file which contains the fix of last used
> directory in file manager.
> Now file manager will remember last used directory per user basis and will
> be store in SQLite database.
>
> Do review it and let us know for comments.
To avoid an exception, I had to change the hunk at line 578 of
file_manager/__init__.py to check for self.dir == None, e.g.
dir = self.dir if self.dir is not None else ''
if not dir.endswith('/'):
dir += '/';
However, I then ran into a problem that if the directory that has been
remembered no longer exists, I get an error message. I believe it
should traverse back up the path to find the closest directory that is
still present.
Can you look at that please?
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Вложения
Hi On Fri, Dec 16, 2016 at 12:08 PM, Neel Patel <neel.patel@enterprisedb.com> wrote: > Hi Dave, > > Please find attached patch file with the fix of below suggestion. > > If the directory that has been remembered no longer exists, then find > closest parent directory to set last remembered directory. > > Do review it and let us know for comments. When I click the File Open button in the SQL Editor, I now get the following exception: 2016-12-16 13:17:45,049: INFO werkzeug: 127.0.0.1 - - [16/Dec/2016 13:17:45] "GET /file_manager/get_trans_id?callback=jQuery11120806574590893895_1481894262193&_=1481894262194 HTTP/1.1" 500 - Traceback (most recent call last): File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 2000, in __call__ return self.wsgi_app(environ, start_response) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1991, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1567, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app response = self.full_dispatch_request() File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request rv = self.dispatch_request() File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask_login.py", line 792, in decorated_view return func(*args, **kwargs) File "/Users/dpage/git/pgadmin4/web/pgadmin/misc/file_manager/__init__.py", line 232, in get_trans_id data={'fileTransId': transid, 'status': True} NameError: global name 'transid' is not defined Coupled with the following from the JS console: 13:32:20.605 SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data <anonymous> utility.js:1182 <anonymous> utility.js:12 .globalEval/<() jquery-1.11.2.js:339 .globalEval() jquery-1.11.2.js:338 .converters["text script"]() jquery-1.11.2.js:9766 ajaxConvert() jquery-1.11.2.js:8838 done() jquery-1.11.2.js:9259 .send/callback() jquery-1.11.2.js:9713 .send() jquery-1.11.2.js:9719 .ajax() jquery-1.11.2.js:9210 jQuery._evalUrl() jquery-1.11.2.js:9368 .domManip() jquery-1.11.2.js:5977 .append() jquery-1.11.2.js:5753 pgAdmin.FileManager.init/</renderStoragePanel/<() file_manager.js:198 jQuery.Callbacks/fire() jquery-1.11.2.js:3143 jQuery.Callbacks/self.fireWith() jquery-1.11.2.js:3255 done() jquery-1.11.2.js:9309 .send/callback() jquery-1.11.2.js:9713 .send() jquery-1.11.2.js:9659 .ajax() jquery-1.11.2.js:9210 pgAdmin.FileManager.init/getTransId() file_manager.js:29 pgAdmin.FileManager.init/</renderStoragePanel() file_manager.js:201 pgAdmin.FileManager.init/</<.main() file_manager.js:225 Alertify/<.dialog/this[name]() alertify.js:2965 pgAdmin.FileManager.show_file_selection() file_manager.js:594 pgAdmin.FileManager.show_dialog() file_manager.js:605 ._open_select_file_manager() sqleditor.js:2454 ._load_file() sqleditor.js:2433 triggerEvents() backbone.js:208 Backbone.Events.trigger() backbone.js:148 SQLEditorView<.on_file_load() sqleditor.js:1498 bound () self-hosted:752 jQuery.event.dispatch() jquery-1.11.2.js:4664 $event.dispatch() jquery.event.drag-2.2.js:374 jQuery.event.add/elemData.handle() jquery-1.11.2.js:4333 1 jquery-1.11.2.js%20line%20339%20%3E%20eval:1182:11 -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hi Dave,
I have tried to reproduce the issue with both python 2 & python3 but no luck and from the logs, it looks like issue with global name 'transid' not defined so i don't think we have changed anything in that logic but yes we need to fix this.
Can you please let me know the steps to reproduce so that i can fix this issue ?
Thanks,
Neel Patel
On Fri, Dec 16, 2016 at 7:06 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
On Fri, Dec 16, 2016 at 12:08 PM, Neel Patel
<neel.patel@enterprisedb.com> wrote:
> Hi Dave,
>
> Please find attached patch file with the fix of below suggestion.
>
> If the directory that has been remembered no longer exists, then find
> closest parent directory to set last remembered directory.
>
> Do review it and let us know for comments.
When I click the File Open button in the SQL Editor, I now get the
following exception:
2016-12-16 13:17:45,049: INFO werkzeug: 127.0.0.1 - - [16/Dec/2016
13:17:45] "GET /file_manager/get_trans_id?callback= jQuery11120806574590893895_ 1481894262193&_=1481894262194
HTTP/1.1" 500 -
Traceback (most recent call last):
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 2000, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask/app.py",
line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- packages/flask_login.py",
line 792, in decorated_view
return func(*args, **kwargs)
File "/Users/dpage/git/pgadmin4/web/pgadmin/misc/file_manager/ __init__.py",
line 232, in get_trans_id
data={'fileTransId': transid, 'status': True}
NameError: global name 'transid' is not defined
Coupled with the following from the JS console:
13:32:20.605 SyntaxError: JSON.parse: unexpected character at line 1
column 1 of the JSON data
<anonymous> utility.js:1182
<anonymous> utility.js:12
.globalEval/<() jquery-1.11.2.js:339
.globalEval() jquery-1.11.2.js:338
.converters["text script"]() jquery-1.11.2.js:9766
ajaxConvert() jquery-1.11.2.js:8838
done() jquery-1.11.2.js:9259
.send/callback() jquery-1.11.2.js:9713
.send() jquery-1.11.2.js:9719
.ajax() jquery-1.11.2.js:9210
jQuery._evalUrl() jquery-1.11.2.js:9368
.domManip() jquery-1.11.2.js:5977
.append() jquery-1.11.2.js:5753
pgAdmin.FileManager.init/</renderStoragePanel/<() file_manager.js:198
jQuery.Callbacks/fire() jquery-1.11.2.js:3143
jQuery.Callbacks/self.fireWith() jquery-1.11.2.js:3255
done() jquery-1.11.2.js:9309
.send/callback() jquery-1.11.2.js:9713
.send() jquery-1.11.2.js:9659
.ajax() jquery-1.11.2.js:9210
pgAdmin.FileManager.init/getTransId() file_manager.js:29
pgAdmin.FileManager.init/</renderStoragePanel() file_manager.js:201
pgAdmin.FileManager.init/</<.main() file_manager.js:225
Alertify/<.dialog/this[name]() alertify.js:2965
pgAdmin.FileManager.show_file_selection() file_manager.js:594
pgAdmin.FileManager.show_dialog() file_manager.js:605
._open_select_file_manager() sqleditor.js:2454
._load_file() sqleditor.js:2433
triggerEvents() backbone.js:208
Backbone.Events.trigger() backbone.js:148
SQLEditorView<.on_file_load() sqleditor.js:1498
bound () self-hosted:752
jQuery.event.dispatch() jquery-1.11.2.js:4664
$event.dispatch() jquery.event.drag-2.2.js:374
jQuery.event.add/elemData.handle() jquery-1.11.2.js:4333
1 jquery-1.11.2.js%20line%20339%20%3E%20eval:1182:11
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Hi On Fri, Dec 23, 2016 at 6:17 AM, Neel Patel <neel.patel@enterprisedb.com> wrote: > Hi Dave, > > I have tried to reproduce the issue with both python 2 & python3 but no luck > and from the logs, it looks like issue with global name 'transid' not > defined so i don't think we have changed anything in that logic but yes we > need to fix this. > > Can you please let me know the steps to reproduce so that i can fix this > issue ? 1) Apply patch and run pgAdmin 2) Open pgAdmin (I'm doing so in Chrome) 3) Browse to a database, and open the query tool 4) Hit the File Open button. Note: I just found I couldn't reproduce this with SERVER_MODE = True, only with SERVER_MODE = False. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hi Dave,
I am able to reproduce the issue with the steps mentioned.
Please find attached patch file for the fix.
I have tested on web and desktop mode. Do review it and let us know for comments.
Thanks,
Neel Patel
On Tue, Jan 3, 2017 at 3:18 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
On Fri, Dec 23, 2016 at 6:17 AM, Neel Patel <neel.patel@enterprisedb.com> wrote:
> Hi Dave,
>
> I have tried to reproduce the issue with both python 2 & python3 but no luck
> and from the logs, it looks like issue with global name 'transid' not
> defined so i don't think we have changed anything in that logic but yes we
> need to fix this.
>
> Can you please let me know the steps to reproduce so that i can fix this
> issue ?
1) Apply patch and run pgAdmin
2) Open pgAdmin (I'm doing so in Chrome)
3) Browse to a database, and open the query tool
4) Hit the File Open button.
Note: I just found I couldn't reproduce this with SERVER_MODE = True,
only with SERVER_MODE = False.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company