[pgadmin-hackers] pgAdmin 4 commit: Improvise the psycopg2 wrapped driver for PostgreSQL

2016-04-04 Thread Ashesh Vashi
Improvise the psycopg2 wrapped driver for PostgreSQL to show formatted
message on demand.

Also - resolved an issue identifying the aborted transaction while using
the asychronous connection.

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=5331075ab003f539bf1e3148a92dd228b62e0e82
Author: Akshay Joshi 

Modified Files
--
web/pgadmin/utils/driver/abstract.py  |  25 ++--
web/pgadmin/utils/driver/psycopg2/__init__.py | 183 +-
2 files changed, 163 insertions(+), 45 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4][Patch] Add formatted error message support in psycopg2

2016-04-04 Thread Ashesh Vashi
Committed with minor change.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*


On Fri, Apr 1, 2016 at 5:17 PM, Akshay Joshi 
wrote:

> Hi
>
> On Fri, Apr 1, 2016 at 3:53 PM, Ashesh Vashi  .com> wrote:
>
>> Hi Akshay,
>>
>> I've update the patch a little bit as discussed offline.
>> Also, renamed the variable 'is_cancel_transaction' to
>> 'execution_aborted', and enum value to 'ASYNC_EXECUTION_ABORTED'.
>>
>
>As per our discussion I have modified the logic and attached is the
> updated patch.
>   Please review it.
>
>
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>> On Thu, Mar 31, 2016 at 4:55 PM, Akshay Joshi <
>> akshay.jo...@enterprisedb.com> wrote:
>>
>>> Hi
>>>
>>> Please ignore the last two patches, While implementing Query Tool I have
>>> found one more issue in poll function when run queries like "create table"
>>> , "insert table". I have added exception handling before fetching the row
>>> from the cursor directly.
>>>
>>> Attached is the modified patch. Please review it and if it looks good
>>> please commit it.
>>>
>>> On Thu, Mar 31, 2016 at 12:37 PM, Akshay Joshi <
>>> akshay.jo...@enterprisedb.com> wrote:
>>>
 Hi

 On Tue, Mar 29, 2016 at 8:09 PM, Akshay Joshi >>> enterprisedb.com> wrote:

> Hi All
>
> While implementing Query Tool, I came to know we need error message's
> with some extra information and also I have faced one issue regarding
> asynchronous connection polling. I have added support for formatted error
> message and also fixed the issue.
>
> Attached is the patch file. Please review it and let me know the
> review comments if any.
>

Apart from above, today I fixed one more issue. In case of user
 cancel the running transaction, poll function of psycopg2 returns
 psycopg2.extensions.POLL_OK, which is mislead by the caller of the
 function, so I have added one flag which will be true if user purposely
 cancel the transaction and from our poll function we return new status i.e.
 ASYNC_CANCEL_TRANSACTION.

  Attached is the modified patch. Please review it and if it looks good
 please commit it.

>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>



 --
 *Akshay Joshi*
 *Principal Software Engineer *



 *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*

>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>


Re: [pgadmin-hackers] Patch: Added select2cell editor for backgrid [pgAdmin4]

2016-04-04 Thread Murtuza Zabuawala
Hi,

PFA updated patch.

Regards,
Murtuza




--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Apr 1, 2016 at 3:08 PM, Ashesh Vashi 
wrote:

> On Thu, Mar 31, 2016 at 12:27 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> We have added Select2Cell Editor for backgrid, eariler as it was not
>> present & causing issue in rendering in subnode control.
>>
> Looks good to me, but - have some feedback.
> 1. Can you please mention - why do we need 'openOnEnter: false' in select2
> options?
> 2. There is a difference between UI, when rendered from the editor, and
> from the Select2Cell. (I can see padding, when the Cell is rendered, but -
> not when editor is rendered.)
>
> Can you please fix this two?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
>>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>


Added_Select2_editor_v2.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] PATCH: pgadmin 4: FTS Parser

2016-04-04 Thread Ashesh Vashi
On Mon, Mar 28, 2016 at 2:32 PM, Sanket Mehta  wrote:

> Hi,
>
> PFA the patch for FTS parser node for review.
> Please do review it and provide the comments.
>
Hi Sanket,

Thanks for the patch.
Please find my review comments.

* 'current_app' has been imported but not used.
* Few variables are assigned, but not used further.
  one of the example: "res = []" (fts_parser/__init__py line#271
* 'gone' is used, but - not imported.
* Do not require __init__(...) function in the 'FtsParserModule' class, as
it does not do anything here.
* Load the module with the database (not, schema), as it may be require to
show in dependencies list in the database.
* Some of the lines/comments are going beyond the line length limit (i.e.
more than 80 character per length).
* Please add comments for all the methods in FtsParserView.
* Do not need the URL routes for get_start, get_token, get_token,
get_headline with id, as it does not use the fts parse id. Declare these
URL-routes without id  for these methods.
* Create separate templates for each methods instead of club them together
for the above methods.
* HTTP method GET implies for getting/fetching the information/data from
the server. Please remove the 'get_' from the above methods,
* Inline comments for __init__ method (FtsParserView class) is missing.
* Do not need to override the 'module_js' method, it has already been
implemented in PGChildNodeView class.
* Please fix the correctness of the comments for all the methods. Avoid
copy/paste from other modules.
* Check for the version before setting the template_path variable in
check_precondition method is not required.
* Check the existence of the node/object before assuming, it is available
(otherwise - return with 'gone') in node, and properties method. SQL may
not fail, but - no of records returned will be 0 (zero).
* Please test the module on Python 3 too.
* Use generate_browser_node from the 'update' method after successful
operation, while generating the result.
* Do not catch exception (if not required) (i.e. in 'update' method, you
will not be able to catch the actual issue in that case). Please remove all
unwanted exceptions.
* Log the exception with the application, whenever we catch them.

Note:
I've not yet tested the patch.
These are the review comments from the python code only.
You may also want to look at the javascript module before sending for
review again.
(i.e. code should be wrapped after the line #79.)

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*



> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>


[pgadmin-hackers] pgAdmin 4 commit: Use separate editor for Select2Cell.

2016-04-04 Thread Ashesh Vashi
Use separate editor for Select2Cell.
This allows us to use the Backgrid key navigation as expected.

This has also resulted into an issue - related unresponsive scrollbar
issue in the SubNodeControl.

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=f7e4e8bea01074fffd0f6f8fc8570a7518ff9137
Author: Murtuza Zabuawala 

Modified Files
--
web/pgadmin/static/css/overrides.css   |   5 +
web/pgadmin/static/js/backgrid/backgrid.pgadmin.js | 145 +++--
2 files changed, 142 insertions(+), 8 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch: Added select2cell editor for backgrid [pgAdmin4]

2016-04-04 Thread Ashesh Vashi
Thanks - committed with small changes.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*


On Mon, Apr 4, 2016 at 1:09 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA updated patch.
>
> Regards,
> Murtuza
>
>
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Apr 1, 2016 at 3:08 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> On Thu, Mar 31, 2016 at 12:27 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> We have added Select2Cell Editor for backgrid, eariler as it was not
>>> present & causing issue in rendering in subnode control.
>>>
>> Looks good to me, but - have some feedback.
>> 1. Can you please mention - why do we need 'openOnEnter: false' in
>> select2 options?
>> 2. There is a difference between UI, when rendered from the editor, and
>> from the Select2Cell. (I can see padding, when the Cell is rendered, but -
>> not when editor is rendered.)
>>
>> Can you please fix this two?
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>>>
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>


[pgadmin-hackers] [pgAdmin4][psycopg2] - Modified status message implementation

2016-04-04 Thread Neel Patel
Hi,

Please find attached patch file which modified the earlier statusmessage
implementation.

*Previous implementation:- *

statusmessage was implemented inside the poll function and if poll result
row is greater than zero then statusmessage was replaced by the result row
returned so if user wants the statusmessage along with returned rows then
current implementation will not work.

*Changes:-*

Now "status_message()" function is implemented to get the status message
returned by last command executed on the server and removed from the poll
function.
If user wants to status messages then they have to call "status_message()"
which will return the status message text.

Do review it and let us know for any comments.

Thanks,
Neel Patel


psycopg2_status_message.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4][Patch]: Backgrid StringDepsCell

2016-04-04 Thread Khushboo Vashi
Hi Ashesh,

I have changed the function name (from *render_deps* to *updateUIDeps*),
which will be called on the dependent field change, as per your suggestion.

Please find attached patch for the same.

Thanks,
Khushboo

On Fri, Apr 1, 2016 at 3:56 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Ashesh,
>
> Yes, agreed. This implementation limits us to use only String Cell.
> So, I have modified the patch as you suggested.
>
> Please find the attachment for the same.
>
> Thanks,
> Khushboo
>
> On Fri, Apr 1, 2016 at 2:59 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Khushboo,
>>
>> I am reluctant to use this code as it is.
>> I would prefer you create just helper functions (i.e. initialize, remove)
>> for the dependents in Backgrid.Cell, and then use them directly from the
>> different cell itself.
>> Because - this functionality limits us to us only with the string type.
>>
>> Anyway - we will be using the dependent functionality for very attributes.
>>
>>
>> You can extend them directly in the Node's model (schema).
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>> On Wed, Mar 30, 2016 at 6:39 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached patch for the Backgrid *StringDepsCell.*
>>>
>>> The *StringDepsCell* displays HTML escaped strings and accepts anything 
>>> typed in.
>>> Also, Listen to the dependent fields.
>>>
>>>
>>> Usage of the Backgrid Cell:
>>>
>>> If the Precision cell is dependent on the Datatype then:
>>>
>>> {
>>>   id: 'precision', label:'{{ _('Precision') }}', type: 'test'
>>>   cell: *Backgrid.Extension.StringDepsCell*, deps: ['datatype']
>>>
>>> }
>>>
>>>
>>> Thanks,
>>> Khushboo
>>>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 4b233d2..9de19fa 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -447,6 +447,46 @@
 editor: TextareaCellEditor
   });
 
+  /**
+DependentCell can be used as a base class for any backgrid cell which is
+dependent on another cell. It will listen to the dependent fields/cells.
+
+Need to Extend this cell whenever required and has to implement updateUIDeps
+function to listen to the dependent fields change event.
+
+@class Backgrid.Extension.DependentCell
+@extends Backgrid.DependentCell
+  */
+  var DependentCell = Backgrid.Extension.DependentCell = Backgrid.Cell.extend({
+initialize: function(){
+  // Listen to the dependent fields in the model for any change
+  var deps = this.column.get('deps');
+  var self = this;
+
+  if (deps && _.isArray(deps)) {
+_.each(deps, function(d) {
+  attrArr = d.split('.');
+  name = attrArr.shift();
+  self.listenTo(self.model, "change:" + name, self.updateUIDeps);
+});
+  }
+},
+remove: function() {
+// Remove the events for the dependent fields in the model
+  var self = this,
+  deps = self.column.get('deps');
+
+  if (deps && _.isArray(deps)) {
+_.each(deps, function(d) {
+  attrArr = d.split('.');
+  name = attrArr.shift();
+  self.stopListening(self.model, "change:" + name, self.updateUIDeps);
+});
+  }
+  Backbone.View.prototype.remove.apply(self, arguments);
+}
+  });
+
   return Backgrid;
 
 }));

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4] [Patch]: Grant Wizard

2016-04-04 Thread Ashesh Vashi
On Wed, Mar 30, 2016 at 5:14 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi,
>
> Please find updated patch.
>
> This patch has following changes:
> 1. Improved code commenting.
> 2. Properly handling memory leak issues in js code.
>
Hi Surinder,

As discussed offline, here are the list of some of the review comments:

* CSS should be relative to its parent element. Please make sure - whenever
you make
  some changes in CSS, it should not affect the existing CSS unless
discussed.

* Change class name for 'error_msg_div' as it is common name. Please name a
class
  with prefixed as the module name.

* Add comments for the blow line changed in node.ui.js file. Always add
logical
  explanation for a change as a comment for any changes.
*while(p && p.length > 0) {*

* Please make sure, we wrap the code around 80 characters for better
readability.
  Line length should not be greater than 80 characters.

* Put the allowed ACLs logic with server version support. We need to be
flexible
  enough to accommodate possible future change in ACLs.

* Avoid using name as reference in each of the given. It will make the
search faster
  in the database and less prone to character conversion issue.
  i.e.
  Use schema/namespace OID instead of nspname, object OID instead of their
name.

* Use separate templates for each type of objects.

* Use the existing functionalities as much as possible instead of
introducing new
  one. That will make the code/results consistent across the application.
  i.e.
  Use existing 'parse_priv_to_db' method, instead of creating new one.

* Please remove unnecessary suffixed white-spaces.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*



>
>
> On Mon, Mar 28, 2016 at 2:09 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch with suggested changes.
>>
>> On Thu, Mar 10, 2016 at 5:26 PM, Dave Page  wrote:
>>
>>> On Thu, Mar 10, 2016 at 9:50 AM, Surinder Kumar
>>>  wrote:
>>> > Please apply Khusboo's patch for "Privileges macros under Schema"
>>> before
>>> > using grant wizard patch.
>>>
>>> Thanks, that works. Some (hopefully final) feedback:
>>>
>>> - Can we add a side-image? Not sure what yet - just a placeholder for
>>> now until I come up with something.
>>>
>> Already a placeholder for left side image.
>>
>>>
>>> - Why is the closed button in an odd position (see File -> Test Alert
>>> for comparison)
>>>
>> Fixed
>>
>>>
>>> - Why are we using a scrolling list AND pagination? I think a
>>> scrolling list alone should be fine.
>>>
>> Pagination is removed.
>>
>>>
>>> - The grid sizing is wrong. See how the scrollbar on the right in the
>>> screenshot is off the edge of the dialogue, and there's a horizontal
>>> scrollbar?
>>>
>> Fixed.
>>
>>>
>>> - We shouldn't truncate object names as that can be ambiguous. The
>>> column should extend as necessary, and there should be a horizontal
>>> scrollbar on the grid itself (not at the bottom of the dialogue
>>> content).
>>>
>> I have fixed it and scrollbar is now on the grid itself.
>>
>>>
>>> - Function names should include the parameters, as they are part of
>>> the identifier. Without, it can be ambigous - e.g. do_stuff(int) vs.
>>> do_stuff(text).
>>>
>> Fixed.
>>
>>>
>>> - If I select only functions (for example), the Privileges panel
>>> should only list privileges available for functions. If I select
>>> multiple object types, it should show the available options for only
>>> those object types.
>>>
>> Implemented this feature.
>>
>>>
>>> - If I select functions and tables, and then choose (for example),
>>> usage and truncate, it will attempt to set usage on tables and
>>> truncate on functions. It should only attempt to set privileges on the
>>> objects for which they are appropriate.
>>>
>> Done
>>
>>>
>>> - On the last page, the Next button is disabled. It is turned a
>>> marginally darker blue, but also highlights on mouse-over. The change
>>> in shade is so subtle it's hard to see, and the highlight implies the
>>> button is active when it isn't.
>>>
>> Fixed.
>>
>>>
>>> - The buttons appear to have a smaller corner radius than those on the
>>> main browser, or in other dialogues.
>>>
>> Fixed.
>>
>>>
>>> - Button labels should have an   before them to properly space
>>> the label from the icon (or better yet, this should be done in CSS,
>>> though that would also need to be done elsewhere).
>>>
>> done with css.
>>
>>>
>>> - Why do the URLs have a /wizard prefix? I think that should be removed.
>>>
>> Removed prefix.
>>
>>>
>>> - The available privileges for each object type seem to be defined in
>>> both grant_wizard.js and allowed_acl.json. Can we just use
>>> allowed_acl.json?
>>>
>> Yes, allowed_acl.json is now used in grant_wizard.js.
>>
>>>
>>> Thanks.
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogs