Changeset 3349 for pykota

Show
Ignore:
Timestamp:
02/28/08 23:39:38 (17 years ago)
Author:
jerome
Message:

Fixed encoding problem with LDAP attribute's names extracted from
pykota.conf : they were unicode strings instead of being UTF-8 (or
even maybe ASCII, but we will use UTF-8).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r3296 r3349  
    2323"""This module defines classes used to parse PyKota configuration files.""" 
    2424 
     25import sys 
    2526import os 
    2627import tempfile 
    2728import ConfigParser 
    2829 
     30from pykota.utils import unicodeToDatabase 
    2931from pykota.errors import PyKotaConfigError     
    3032 
     
    9799        backendinfo["storagebackend"] = backend 
    98100        if backend == "sqlitestorage" : 
    99             issqlite = 1 
     101            issqlite = True 
    100102            backendinfo["storagename"] = self.getGlobalOption("storagename") 
    101103            for option in ["storageserver", "storageuser", "storageuserpw"] : 
    102104                backendinfo[option] = None           
    103105        else : 
    104             issqlite = 0 
     106            issqlite = False 
    105107            for option in ["storageserver", "storagename", "storageuser"] : 
    106108                backendinfo[option] = self.getGlobalOption(option) 
     
    151153                        "usermail", \ 
    152154                      ] : 
    153             ldapinfo[option] = self.getGlobalOption(option).strip() 
     155            ldapinfo[option] = unicodeToDatabase(self.getGlobalOption(option).strip()) 
    154156        for field in ["newuser", "newgroup"] : 
    155157            if ldapinfo[field].lower().startswith('attach(') : 
     
    160162        ldapinfo["cacert"] = self.getGlobalOption("cacert", ignore=True) 
    161163        if ldapinfo["cacert"] : 
    162             ldapinfo["cacert"] = ldapinfo["cacert"].strip() 
     164            ldapinfo["cacert"] = ldapinfo["cacert"].strip().encode(sys.getfilesystemencoding(), "replace") 
    163165        if ldapinfo["ldaptls"] :     
    164166            if not os.access(ldapinfo["cacert"] or "", os.R_OK) : 
    165                 raise PyKotaConfigError, _("Option ldaptls is set, but certificate %s is not readable.") % str(ldapinfo["cacert"]) 
     167                raise PyKotaConfigError, _("Option ldaptls is set, but certificate %s is not readable.") % repr(ldapinfo["cacert"]) 
    166168        return ldapinfo 
    167169