Changeset 2804
- Timestamp:
- 03/25/06 22:22:07 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pknotify
r2802 r2804 152 152 def sanitizeMessage(self, msg) : 153 153 """Replaces \\n and returns a messagee in xmlrpclib Binary format.""" 154 return xmlrpclib.Binary( msg.replace("\\n", "\n"))154 return xmlrpclib.Binary(self.userCharsetToUTF8(msg.replace("\\n", "\n"))) 155 155 156 156 def convPAM(self, auth, queries=[], userdata=None) : … … 243 243 if options["checkauth"] : 244 244 if ("username" in varnames) and ("password" in varnames) : 245 if self.checkAuth(result["username"].data, result["password"].data) : 245 if self.checkAuth(self.UTF8ToUserCharset(result["username"].data[:]), 246 self.UTF8ToUserCharset(result["password"].data[:])) : 246 247 authok = "AUTH=YES" 247 248 else : … … 252 253 if (varname != "password") \ 253 254 and ((varname != "username") or (authok in (None, "AUTH=YES"))) : 254 print "%s=%s" % (varname.upper(), result[varname].data)255 print "%s=%s" % (varname.upper(), self.UTF8ToUserCharset(result[varname].data[:])) 255 256 if authok is not None : 256 257 print authok … … 275 276 try : 276 277 defaults = { \ 277 "denyafter" : 1,278 "denyafter" : 0, 278 279 "timeout" : 0, 279 280 } -
pykota/trunk/pykota/storage.py
r2801 r2804 646 646 def databaseToUserCharset(self, text) : 647 647 """Converts from database format (UTF-8) to user's charset.""" 648 if text is not None : 649 try : 650 return unicode(text, "UTF-8").encode(self.tool.getCharset()) 651 except UnicodeError : 652 try : 653 # Incorrect locale settings ? 654 return unicode(text, "UTF-8").encode("ISO-8859-15") 655 except UnicodeError : 656 pass 657 return text 648 return self.tool.UTF8ToUserCharset(text) 658 649 659 650 def userCharsetToDatabase(self, text) : 660 651 """Converts from user's charset to database format (UTF-8).""" 661 if text is not None : 662 try : 663 return unicode(text, self.tool.getCharset()).encode("UTF-8") 664 except UnicodeError : 665 try : 666 # Incorrect locale settings ? 667 return unicode(text, "ISO-8859-15").encode("UTF-8") 668 except UnicodeError : 669 pass 670 return text 652 return self.tool.userCharsetToUTF8(text) 671 653 672 654 def cleanDates(self, startdate, enddate) : -
pykota/trunk/pykota/tool.py
r2795 r2804 236 236 """Returns the charset in use.""" 237 237 return self.charset 238 239 def UTF8ToUserCharset(self, text) : 240 """Converts from UTF-8 to user's charset.""" 241 if text is not None : 242 try : 243 return unicode(text, "UTF-8").encode(self.charset) 244 except UnicodeError : 245 try : 246 # Incorrect locale settings ? 247 return unicode(text, "UTF-8").encode("ISO-8859-15") 248 except UnicodeError : 249 pass 250 return text 251 252 def userCharsetToUTF8(self, text) : 253 """Converts from user's charset to UTF-8.""" 254 if text is not None : 255 try : 256 return unicode(text, self.charset).encode("UTF-8") 257 except UnicodeError : 258 try : 259 # Incorrect locale settings ? 260 return unicode(text, "ISO-8859-15").encode("UTF-8") 261 except UnicodeError : 262 pass 263 return text 238 264 239 265 def display(self, message) :