public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: PATCH: To fix salt generation in session.py
Date: Mon, 11 Jul 2016 12:41:56 +0530
Message-ID: <CAKKotZTcPrR6uWqPUSCrgObfLVwEp4ECb14tqpNPi9vJcY4+bA@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

With latest pull session.py fails with below error with python3 because in
python3 strings 'lowercase' method has been renamed to 'ascii_lowercase',
PFA patch to fix the issue.

Issue:
----------
*  File "../pgadmin4/web/pgadmin/utils/session.py", line 59, in sign*
*    self.randval = ''.join(random.sample(string.lowercase+string.digits,
20))*
*AttributeError: module 'string' has no attribute 'lowercase'*


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


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


Attachments:

  [application/octet-stream] Fix_sessions.patch (895B, 3-Fix_sessions.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/session.py b/web/pgadmin/utils/session.py
index 9f740f5..0dcca4d 100644
--- a/web/pgadmin/utils/session.py
+++ b/web/pgadmin/utils/session.py
@@ -56,7 +56,15 @@ class ManagedSession(CallbackDict, SessionMixin):
 
     def sign(self, secret):
         if not self.hmac_digest:
-            self.randval = ''.join(random.sample(string.lowercase+string.digits, 20))
+            # If script is running under python2
+            if hasattr(string, 'lowercase'):
+                population = string.lowercase
+            # If script is running under python3
+            elif hasattr(string, 'ascii_lowercase'):
+                population = string.ascii_lowercase
+            population += string.digits
+
+            self.randval = ''.join(random.sample(population, 20))
             self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval), secret)
 
 


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PATCH: To fix salt generation in session.py
  In-Reply-To: <CAKKotZTcPrR6uWqPUSCrgObfLVwEp4ECb14tqpNPi9vJcY4+bA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox