Bug 46575 - pykota postgresql handling broken
pykota postgresql handling broken
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Printserver - pykota
UCS 4.3
Other Linux
: P5 normal (vote)
: UCS 4.3
Assigned To: Felix Botner
UCS maintainers
: interim-4
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-09 15:45 CET by Felix Botner
Modified: 2018-04-14 13:34 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
python-pygresql-stuff.patch (2.21 KB, patch)
2018-03-09 17:16 CET, Felix Botner
Details | Diff
debian-stuff.patch (12.71 KB, patch)
2018-03-09 17:16 CET, Felix Botner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Botner univentionstaff 2018-03-09 15:45:31 CET
ERROR: PyKota v1.26_fixes_official
ERROR: pkusers failed
ERROR: Traceback (most recent call last):
ERROR:   File "/usr/bin/pkusers", line 406, in <module>
ERROR:     manager.deferredInit()
ERROR:   File "/usr/lib/pymodules/python2.7/pykota/tool.py", line 457, in deferredInit
ERROR:     self.storage = storage.openConnection(self)
ERROR:   File "/usr/lib/pymodules/python2.7/pykota/storage.py", line 866, in openConnection
ERROR:     return storagebackend.Storage(pykotatool, host, database, admin, adminpw)
ERROR:   File "/usr/lib/pymodules/python2.7/pykota/storages/pgstorage.py", line 65, in __init__
ERROR:     self.quote = pg._quote
ERROR: AttributeError: 'module' object has no attribute '_quote'


seems that pykota is too old for the new python-pygresql
Comment 1 Felix Botner univentionstaff 2018-03-09 17:16:02 CET
update the pykota package, 

* some necessary changes for debian package
* update of the pykota-postgresql.sql file (see Bug #46570)
* fix for storages/pgstorage.py


i replaced quota with database.adapter.adapt_inline, which seem to be the new way to do it (?)

+++ pykota-1.27.0/pykota/storages/pgstorage.py	2018-03-09 15:48:33.000000000 +0100
@@ -60,10 +60,6 @@
             raise PGError, msg
         self.closed = 0
         try :
-            self.quote = self.database._quote
-        except AttributeError : # pg <v4.x
-            self.quote = pg._quote
-        try :
             self.database.query("SET CLIENT_ENCODING TO 'UTF-8';")
         except PGError, msg :
             self.tool.logdebug("Impossible to set database client encoding to UTF-8 : %s" % msg)
@@ -137,15 +133,7 @@
 
     def doQuote(self, field) :
         """Quotes a field for use as a string in SQL queries."""
-        if type(field) == type(0.0) :
-            typ = "decimal"
-        elif type(field) == type(0) :
-            typ = "int"
-        elif type(field) == type(0L) :
-            typ = "int"
-        else :
-            typ = "text"
-        return self.quote(field, typ)
+        return self.database.adapter.adapt_inline(field)
Comment 2 Felix Botner univentionstaff 2018-03-09 17:16:33 CET
Created attachment 9460 [details]
python-pygresql-stuff.patch
Comment 3 Felix Botner univentionstaff 2018-03-09 17:16:50 CET
Created attachment 9461 [details]
debian-stuff.patch
Comment 4 Stefan Gohmann univentionstaff 2018-03-10 21:37:31 CET
Tests: OK, I've installed a UCS 4.3 and tested the printquota settings for one user.

Changelog: OK
Comment 5 Stefan Gohmann univentionstaff 2018-03-14 14:38:41 CET
UCS 4.3 has been released:
 https://docs.software-univention.de/release-notes-4.3-0-en.html
 https://docs.software-univention.de/release-notes-4.3-0-de.html

If this error occurs again, please use "Clone This Bug".