Changeset 2593 for pykota/trunk/pykota
- Timestamp:
- 11/29/05 12:43:34 (18 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/config.py
r2583 r2593 95 95 """Returns the storage backend information as a Python mapping.""" 96 96 backendinfo = {} 97 for option in [ "storagebackend", "storageserver", \ 98 "storagename", "storageuser", \ 99 ] : 100 backendinfo[option] = self.getGlobalOption(option) 101 backendinfo["storageuserpw"] = self.getGlobalOption("storageuserpw", ignore=1) # password is optional 97 backend = self.getGlobalOption("storagebackend").lower() 98 backendinfo["storagebackend"] = backend 99 if backend == "sqlitestorage" : 100 issqlite = 1 101 backendinfo["storagename"] = self.getGlobalOption("storagename") 102 for option in ["storageserver", "storageuser", "storageuserpw"] : 103 backendinfo[option] = None 104 else : 105 issqlite = 0 106 for option in ["storageserver", "storagename", "storageuser"] : 107 backendinfo[option] = self.getGlobalOption(option) 108 backendinfo["storageuserpw"] = self.getGlobalOption("storageuserpw", ignore=1) # password is optional 109 102 110 backendinfo["storageadmin"] = None 103 111 backendinfo["storageadminpw"] = None … … 109 117 backendinfo["storageadmin"] = adminconf.get("global", "storageadmin", raw=1) 110 118 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) : 111 raise PyKotaConfigError, _("Option %s not found in section global of %s") % ("storageadmin", self.adminfilename) 119 if not issqlite : 120 raise PyKotaConfigError, _("Option %s not found in section global of %s") % ("storageadmin", self.adminfilename) 112 121 try : 113 122 backendinfo["storageadminpw"] = adminconf.get("global", "storageadminpw", raw=1) -
pykota/trunk/pykota/storages/pgstorage.py
r2418 r2593 118 118 typ = "text" 119 119 return pg._quote(field, typ) 120 121 def prepareRawResult(self, result) : 122 """Prepares a raw result by including the headers.""" 123 if result.ntuples() > 0 : 124 entries = [result.listfields()] 125 entries.extend(result.getresult()) 126 nbfields = len(entries[0]) 127 for i in range(1, len(entries)) : 128 fields = list(entries[i]) 129 for j in range(nbfields) : 130 field = fields[j] 131 if type(field) == StringType : 132 fields[j] = self.databaseToUserCharset(field) 133 entries[i] = tuple(fields) 134 return entries 135 -
pykota/trunk/pykota/storages/sqlitestorage.py
r2591 r2593 123 123 else : 124 124 return "NULL" 125 126 def prepareRawResult(self, result) : 127 """Prepares a raw result by including the headers.""" 128 if result : 129 entries = [tuple([f[0] for f in self.cursor.description])] 130 for entry in result : 131 row = [] 132 for value in entry : 133 try : 134 value = value.encode("UTF-8") 135 except : 136 pass 137 row.append(value) 138 entries.append(tuple(row)) 139 return entries 140 -
pykota/trunk/pykota/storages/sql.py
r2464 r2593 30 30 31 31 class SQLStorage : 32 def prepareRawResult(self, result) :33 """Prepares a raw result by including the headers."""34 if result.ntuples() > 0 :35 entries = [result.listfields()]36 entries.extend(result.getresult())37 nbfields = len(entries[0])38 for i in range(1, len(entries)) :39 fields = list(entries[i])40 for j in range(nbfields) :41 field = fields[j]42 if type(field) == StringType :43 fields[j] = self.databaseToUserCharset(field)44 entries[i] = tuple(fields)45 return entries46 47 32 def createFilter(self, only) : 48 33 """Returns the appropriate SQL filter.""" -
pykota/trunk/pykota/version.py
r2588 r2593 22 22 # 23 23 24 __version__ = "1.24alpha 3_unofficial"24 __version__ = "1.24alpha4_unofficial" 25 25 26 26 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS."