Commit Graph

43 Commits

Author SHA1 Message Date
Murtuza Zabuawala
bc63652811 Fix the issue where Import/Export was failing in linux runtime. Fixes #2166
Issue:
Changes done by Ashesh in pgAdmin4.py file for setting up PYTHONHOME variable to sys.prefix was applicable only for windows only.

Additionally I have also added exception handling for file provided by user for Backup/Restore/Import/Export.
2017-03-09 09:54:55 +00:00
Ashesh Vashi
f2fc1ceba8 Resolved quite a few file-system encoding/decoding related cases.
In order to resolve the non-ascii characters in path (in user directory,
storage path, etc) on windows, we have converted the path into the
short-path, so that - we don't need to deal with the encoding issues
(specially with Python 2).

We've resolved majority of the issues with this patch.
We still need couple issues to resolve after this in the same area.

TODO
* Add better support for non-ascii characters in the database name on
  windows with Python 3
* Improve the messages created after the background processes by
  different modules (such as Backup, Restore, Import/Export, etc.),
  which does not show short-paths, and xml representable characters for
  non-ascii characters, when found in the database objects, and the file
  PATH.

Fixes #2174, #1797, #2166, #1940

Initial patch by: Surinder Kumar
Reviewed by: Murtuza Zabuawala
2017-03-07 15:31:03 +05:30
Dave Page
6696b3c316 Authenticate the runtime to the server. Fixes #2228 2017-03-06 14:53:49 +00:00
Atira Odhner
fe1aec5de0 Add feature test framework, using selenium and chromedriver for UI testing.
Written by both George and Atira at Pivotal.
2017-02-22 12:41:28 +00:00
Ashesh Vashi
2f6a0e01da Ensure that PYTHONHOME is set for sub-processes such as the background executor. 2017-02-10 22:42:44 +00:00
Dave Page
f221194bcc Update copyright notices for 2017. 2017-01-04 13:33:32 +00:00
Dave Page
bc5cc964a3 Move security keys into the SQLite database, and auto-generate them.
This avoids packagers having to deal with the issue, which can be
difficult if they need to cater for both server and desktop modes.

Fixes #1849
2016-10-19 09:22:38 +01:00
Murtuza Zabuawala
8d7b840e7e Fix startup navigation message. 2016-08-23 12:41:41 +01:00
Dave Page
050937a32a Fix WSGI support. 2016-08-18 13:43:00 +01:00
Dave Page
d63b54610b Move the config database schema version out of the configuration file and into the model class.
Turns out using the config file isn't a good idea if users copy config.py to config_local.py, as it prevents upgrades to the database. This has the added side-effect of simplifying future changes, as you only need to edit 2 files to modify the config DB now, not 3.
2016-06-24 12:50:52 +01:00
Ashesh Vashi
a35288e25d Save the runtime status information in the application object for using
it other places.

globals() does not return consistent value across the application
context.

Thanks Neel Patel for reporting the issue.
2016-06-21 15:13:04 +05:30
Dave Page
262ae7d28c Improve detection of the runtime environment, and subsequent self-configuration. 2016-06-17 10:03:32 +01:00
Dave Page
bc16a1a61f Don't output the startup message in Desktop mode as it hangs the runtime
on Windows.
2016-06-16 17:13:32 +01:00
Dave Page
0f12defd20 Tell the user where the app server is running. 2016-06-14 12:00:06 +01:00
Sebastiaan van Stijn
8b770ae479 Fix "global name 'execfile' not defined".
execfile was removed in Python 3.0. This
uses 'exec(open(filename).read())' as an
alternative, which works on all Python
versions.
2016-06-13 16:24:54 +01:00
Murtuza Zabuawala
d202366a5d Fixes #1185 - While connecting to the server, application becomes almost
inaccessible.

In stand (without threaded) mode, flask application is not able to
process more than one request at a time. Hence - even the client
(browser) send multiple request, when connecting the server (which is
inaccessible), rest of operations get blocked, as making the connection
with the database server is blocking operation.

In order to fix the issue, we're starting the application with thread
support, in which it will create a separate thread of each request.
2016-06-02 14:51:33 +05:30
Paresh More
0dabbf3dad Auto-run setup.py if the config database doesn't exist. 2016-05-26 13:00:27 +01:00
Murtuza Zabuawala
3eb51e93e7 Allow Werkzeug to be configured to bind to adaptors other than localhost for testing. 2016-05-06 15:25:52 +01:00
Dave Page
694506453b Copyright updates for 2016. 2016-01-18 14:48:14 +00:00
Murtuza Zabuawala
209ee78b25 First round of Python 3 compatibility fixes. 2015-11-06 10:23:19 +00:00
Ashesh Vashi
e27e39a8f3 Added support for the infrastructure for on demand access/create the
server connection.

The BaseDriver and BaseConnection are two abstract classes, which allows
us to replace the existing driver with the currently used. The current
implementation supports to connect the PostgreSQL and Postgres Plus
Advanced Server using the psycopg2 driver.
2015-10-20 12:33:29 +05:30
Ashesh Vashi
aa150030eb Introduced a mechanism to load required javascripts at runtime
(lazy loading) using the require.js. This allows us to load the
javascript required for any node, only when it was loaded in the browser
tree. Also, introduced the mechanism to show/edit/create of any node in
a tab panel (wcDocker.Panel).
2015-06-30 11:21:57 +05:30
Ashesh Vashi
35d01bea3e Introduced a class - NodeView to achieve REST API required by the
PostgreSQL node(s).

Browser Tree Node (PostgreSQL object) requires more than just CRUD.
i.e.
   - CRUD (Create, Read, Update & Delete)
    - Reversed Engineered SQL for the object
    - Modified Query in edit mode
      i.e. ALTER TABLE ...
    - Statistics
    - List of dependents
    - List of dependencies
    - Children node list

This class can be inherited to achieve the different routes for each of
the object types/collections.

    OPERATION      |              URL       | Method
    ---------------+------------------------+--------
    List           | /obj/[Parent URL]/     | GET
    Properties     | /obj/[Parent URL]/id   | GET
    Create         | /obj/[Parent URL]/     | POST
    Delete         | /obj/[Parent URL]/id   | DELETE
    Update         | /obj/[Parent URL]/id   | PUT

    SQL (Reversed  | /sql/[Parent URL]/id   | GET
    Engineering)   |
    SQL (Modified  | /sql/[Parent URL]/id   | POST
    Properties)    |

    Statistics     | /stats/[Parent URL]/id | GET
    Dependencies   | /deps/[Parent URL]/id  | GET
    Dependents     | /deps/[Parent URL]/id  | POST

    Children Nodes | /nodes/[Parent URL]/id | GET

    NOTE:
    Parent URL can be seen as the path to identify the particular node.

    i.e.
     In order to identify the TABLE object, we requires information
     about the server -> database -> schema objects.

     Hence, the Parent URL for the TABLE object will be something like
     this as below:
     <int:sid>/<str:database>/<str:schema>

Inherited a new classes ServerGroupView and ServerView, which are
inherited from the NodeView for the implementation of above operations.
2015-06-29 13:41:56 +05:30
Ronan Dunklau
eb6580b43a Introduced a PgAdmin class inherited from the Flask, which looks for
submodules inherited from the PgAdminModule instead of regular
Blueprint. This allows us to load the module automatically from the
under the pgadmin directory, and will work to extend the pgAdmin
extension module.

PgAdminModule is inherited from the Blueprint, and bring several
methods:
-  get_own_stylesheets, which returns the stylesheets used by the module
   (excluding its submodules stylesheets)
- get_own_javascripts
- menu_items, which returns a dictionray mapping the old hook names
  (context_items etc) to a list of MenuItem instances

For more specialized modules (as for now, any module that should be part
of the browser tree construction), one can define an abstract base class
defining additional methods.

For example, the BrowserPluginModule abstract base class defines the
following methods:
- jssnippets
- csssnipeets
- node_type
- get_nodes
2015-06-29 12:28:41 +05:30
Dave Page
fe834d1ed2 Re-organise node structure and loading to make things somewhat more
simple. This also adds the ability to display servers on the treeview.
2015-03-10 13:09:11 +00:00
Dave Page
613df8b596 Copyright year fixes and doc tweaks. 2015-02-25 20:25:41 +00:00
Dave Page
bb6a3f9b5b Use minified output when not in debug mode, and non-minified when debugging.
Update jQuery while we're at it.
2015-02-12 10:28:15 +00:00
Dave Page
7c60fb3377 Support a desktop authentication mode.
This uses a single default user in the config database, which is
auto-logged into the app when SERVER_MODE = False. In this mode we
also hide/remove user-related functions in the UI.
2015-01-26 15:20:28 +00:00
Dave Page
7fa40d7671 Use Python docsctrings 2015-01-21 12:00:13 +00:00
Dave Page
dd40207617 Don't run the webserver in debug mode as it breaks the runtime. 2015-01-20 13:51:20 +00:00
Dave Page
7b8cb207ab Support dynamically loaded modules. 2015-01-20 12:32:06 +00:00
Dave Page
b9bf6d9aa3 Restructure to enable use of modules for different components of pgAdmin. 2014-12-18 17:49:09 +00:00
Dave Page
255d6c1437 Improve commenting 2014-12-17 15:27:54 +00:00
Dave Page
417ad2c6ee Make the application name and version details configurable. 2014-12-17 12:52:43 +00:00
Dave Page
3e6436bc9b Prevent werkzeug starting up it's own stream handler so that all
messages are routed through pgAdmin's handlers.
2014-12-17 12:44:07 +00:00
Dave Page
a0628f4a84 Ensure requests to the web server hit the file log too. 2014-12-16 18:21:26 +00:00
Dave Page
53389d6ee0 Enable static file handling. 2014-12-16 18:10:07 +00:00
Dave Page
ba939f27d7 Use multiple logging handlers so we can have messages going to both
the console and a file, with differing formats and levels.
2014-12-16 17:14:48 +00:00
Dave Page
2d21ea059b Add a basic logging system. 2014-12-16 15:54:29 +00:00
Dave Page
cd9d005c49 Remove CherryPy from the source tree, and change references to Flask
instead. Add support to the runtime to allow the user to specify the
Python path. This needs to be more automated for release, but will be
useful for debugging and development.
2014-12-16 12:53:09 +00:00
Dave Page
e120c43663 Add a "ping" handler. 2013-10-04 21:48:01 +01:00
Dave Page
457a842cec Find a random port number to use for the application server to avoid conflicts
with any other apps that may have already bound to the default port used by CP.
2013-10-04 21:48:01 +01:00
Dave Page
28f45ea9f9 Initial PoC of a CherryPy app integrate with the runtime.
Upon startup, the runtime will attempt to locate pgAdmin4.py in a
number of different relative locations. Once found, it will execute
it in a new thread. The main window is then created and the brower's
initial page is set to the root of the CherryPy server. At present,
that's http://127.0.0.1:8080.
2013-06-21 23:21:11 +01:00