[web2py] DAL , pymysql

2013-08-28 Thread Orrù

Hi,
I have two applications running: the application A is an instance of 
web2py and application B is based on the DAL standalone, aplications A 
and B, both  with  to migrate=False , to connecting to the same DB 
(mysql server).
*Sometimes the two fail* and return the following error:

Application A (web2py):
type 'exceptions.RuntimeError' Failure to connect, tried 5 times: 
Traceback (most recent call last): File 
/home/nabladel/web2py/web2py/gluon/dal.py, line 7276, in __init__ 
self._adapter = ADAPTERS[self._dbname](**kwargs) File 
/home/nabladel/web2py/web2py/gluon/dal.py, line 2483, in __init__ if 
do_connect: self.reconnect() File 
/home/nabladel/web2py/web2py/gluon/dal.py, line 596, in reconnect 
self.connection = f() File /home/nabladel/web2py/web2py/gluon/dal.py, 
line 2481, in connector return self.driver.connect(**driver_args) File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/__init__.py, line 93, 
in Connect return Connection(*args, **kwargs) File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/connections.py, line 
575, in __init__ self._connect() File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/connections.py, line 
740, in _connect self._get_server_information() File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/connections.py, line 
907, in _get_server_information self.server_charset = 
charset_by_id(self.server_language).name File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/charset.py, line 173, 
in charset_by_id return _charsets.by_id(id) File 
/home/nabladel/web2py/web2py/gluon/contrib/pymysql/charset.py, line 21, 
in by_id return self._by_id[id] KeyError: 110 

Application B (DAL standalone):
DEBUG: connect attempt 0, connection error:
Traceback (most recent call last):
  File /home/nabladel/aplication/gluon/dal.py, line 7351, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File /home/nabladel/aplication/gluon/dal.py, line 2499, in __init__
if do_connect: self.reconnect()
  File /home/nabladel/aplication/gluon/dal.py, line 592, in reconnect
self.connection = f()
  File 
/home/nabladel/aplication/MinimalModbus-0.4/icontrol4/gluon/dal.py, line 
2497, in connector
return self.driver.connect(**driver_args)
  File /home/nabladel/aplication/gluon/contrib/pymysql/__init__.py, line 
93, in Connect
return Connection(*args, **kwargs)
  File /home/nabladel/aplication/gluon/contrib/pymysql/connections.py, 
line 575, in __init__
self._connect()
  File /home/nabladel/aplication/gluon/contrib/pymysql/connections.py, 
line 740, in _connect
self._get_server_information()
  File /home/nabladel/aplication/gluon/contrib/pymysql/connections.py, 
line 907, in _get_server_information
self.server_charset = charset_by_id(self.server_language).name
  File /home/nabladel/aplication/gluon/contrib/pymysql/charset.py, line 
173, in charset_by_id
return _charsets.by_id(id)
  File /home/nabladel/aplication/gluon/contrib/pymysql/charset.py, line 
21, in by_id
return self._by_id[id]
KeyError: 110

application B I start through the python IDLE, web2py out error only 
when I close IDLE.
web2py: Version 2.4.2 stable
can someone help me?


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: How to check if plain text password matches with encrypted password in auth_user.password?

2013-04-05 Thread Orrù

suppose password='12345' and db.auth_user.first_name=='Lucas'
so i find user by first_name,
row_user=db(db.auth_user.first_name=='Lucas').select().first()
and 
row_user.password='pbkdf2(1000,20,sha512)$97448b22487eca1d$dae65c0429430b7ae7bb311fed8e844b6a37ff30'

db.auth_user.password.validate('12345') == 
(db(db.auth_user.id==row_user.id).select ().first ().password, None) 
return False
CRYPT()('12345')==(row_user.password,None)
also returns false

where I am going wrong?

On Friday, December 21, 2012 11:12:26 PM UTC-2, Pearu Peterson wrote:

 Hi,

 I have a password in plain text and I want to check if it matches with the 
 crypted password in auth_user.password field.

 I have tried comparing auth_user.password with 
 str(db.auth_user.password.validate(plain_password)[0]) with no success even 
 when I know that the passwords match exactly.

 The problem seems to boil down to the fact that encryption of the same 
 string results different encrypted strings. For example,
  from gluon.validators import CRYPT, LazyCrypt
  crypt = CRYPT()
  str(LazyCrypt(crypt, 'mysecret'))
 
 'pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff'
  str(LazyCrypt(crypt, 'mysecret'))
 
 'pbkdf2(1000,20,sha512)$a555a267249876fb$bc18f82b72a3a5ebce617f32d6abaa5c48734ab9'

 What would be the correct way to check if passwords match when they are 
 given in encrypted form?

 Any hints are appreciated,
 Pearu



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.