[R] use dbhelper.binary_value to process passwords and other Bytes fields
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 01 Oct 2010 16:07:03 +0200
changeset 6379 3f67f7ea5632
parent 6378 5a86a0c147bd
child 6380 63d5dbaef999
[R] use dbhelper.binary_value to process passwords and other Bytes fields (instead of dbapi_module.Binary or hardcoding buffer()). This requires (esp. in serverctl) version 1.3.1 of logilab.database. Dependencies updated.
__pkginfo__.py
debian/control
server/serverctl.py
server/sqlutils.py
--- a/__pkginfo__.py	Fri Oct 01 15:45:38 2010 +0200
+++ b/__pkginfo__.py	Fri Oct 01 16:07:03 2010 +0200
@@ -52,7 +52,7 @@
     'Twisted': '',
     # XXX graphviz
     # server dependencies
-    'logilab-database': '>= 1.3.0',
+    'logilab-database': '>= 1.3.1',
     'pysqlite': '>= 2.5.5', # XXX install pysqlite2
     }
 
--- a/debian/control	Fri Oct 01 15:45:38 2010 +0200
+++ b/debian/control	Fri Oct 01 16:07:03 2010 +0200
@@ -33,7 +33,7 @@
 Conflicts: cubicweb-multisources
 Replaces: cubicweb-multisources
 Provides: cubicweb-multisources
-Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.3.0), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2
+Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.3.1), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2
 Recommends: pyro, cubicweb-documentation (= ${source:Version})
 Description: server part of the CubicWeb framework
  CubicWeb is a semantic web application framework.
--- a/server/serverctl.py	Fri Oct 01 15:45:38 2010 +0200
+++ b/server/serverctl.py	Fri Oct 01 16:07:03 2010 +0200
@@ -486,6 +486,9 @@
             print '-> Error: could not get cubicweb administrator login.'
             sys.exit(1)
         cnx = source_cnx(sourcescfg['system'])
+        driver = sourcescfg['system']['db-driver']
+        from logilab.database import get_db_helper
+        dbhelper = get_db_helper(driver)
         cursor = cnx.cursor()
         # check admin exists
         cursor.execute("SELECT * FROM cw_CWUser WHERE cw_login=%(l)s",
@@ -501,7 +504,7 @@
                                        passwdmsg='new password for %s' % adminlogin)
         try:
             cursor.execute("UPDATE cw_CWUser SET cw_upassword=%(p)s WHERE cw_login=%(l)s",
-                           {'p': buffer(crypt_password(passwd)), 'l': adminlogin})
+                           {'p': dbhelper.binary_value(crypt_password(passwd)), 'l': adminlogin})
             sconfig = Configuration(options=USER_OPTIONS)
             sconfig['login'] = adminlogin
             sconfig['password'] = passwd
--- a/server/sqlutils.py	Fri Oct 01 15:45:38 2010 +0200
+++ b/server/sqlutils.py	Fri Oct 01 16:07:03 2010 +0200
@@ -165,7 +165,7 @@
         self.OperationalError = dbapi_module.OperationalError
         self.InterfaceError = dbapi_module.InterfaceError
         self.DbapiError = dbapi_module.Error
-        self._binary = dbapi_module.Binary
+        self._binary = self.dbhelper.binary_value
         self._process_value = dbapi_module.process_value
         self._dbencoding = dbencoding