Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-31-2010, 10:15 AM   #1
koehli
Junior Member
koehli began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Nov 2009
Device: Sony 505PRS
[Bug + Patch] UnicodeDecodeError in new contentserver browse mode

Hello Kovid,

The new contentserver (calibre 0.7.26) is broken with non-US (e.g. German) databases and localisation.

Output of the webpage e.g. when clicking on
http://127.0.0.1:8080/browse/category/newest

Code:
500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/local/lib/calibre/cherrypy/_cprequest.py", line 606, in respond
    cherrypy.response.body = self.handler()
  File "/usr/local/lib/calibre/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/local/lib/calibre/calibre/library/server/utils.py", line 49, in do
    ans = func(*args, **kwargs)
  File "/usr/local/lib/calibre/calibre/library/server/browse.py", line 174, in do
    ans = func(self, *args, **kwargs)
  File "/usr/local/lib/calibre/calibre/library/server/browse.py", line 545, in browse_matches
    return self.browse_template(sort, category=False).format(
  File "/usr/local/lib/calibre/calibre/library/server/browse.py", line 257, in browse_template
    ans = ans.replace('{library_name}', xml(os.path.basename(lp)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3526: ordinal not in range(128)
The following little patch fixes these encoding issues for me:

Code:
--- src/calibre/library/server/browse.py        2010-10-30 20:53:58.000000000 +0200
+++ src/calibre/library/server/browse.patched.py        2010-10-31 13:53:54.627473906 +0100
@@ -252,8 +252,6 @@
         lp = self.db.library_path
         if isbytestring(lp):
             lp = force_unicode(lp, filesystem_encoding)
-        if isinstance(ans, unicode):
-            ans = ans.encode('utf-8')
         ans = ans.replace('{library_name}', xml(os.path.basename(lp)))
         ans = ans.replace('{library_path}', xml(lp, True))
         ans = ans.replace('{initial_search}', initial_search)
Please apply, if appropriate.

Thanks for the great program,

Felix

Last edited by koehli; 10-31-2010 at 10:19 AM. Reason: forgot version information
koehli is offline   Reply With Quote
Old 10-31-2010, 12:28 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,328
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Thanks, fixed.
kovidgoyal is offline   Reply With Quote
 
Advertisement
Reply

Tags
bugreports, patches

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
UnicodeDecodeError in startup.py yet Calibre 3 02-05-2010 12:29 PM
UnicodeDecodeError in startup.py yet Calibre 0 02-04-2010 06:57 AM
Convert LIT bug & patch llasram Workshop 4 12-30-2007 05:05 PM
PRS-505 bug or eBookLib bug? porkupan Sony Reader 3 10-07-2007 11:44 PM
Bug turns iRex iLiad into color-mode Alexander Turcic Lounge 4 06-08-2007 10:43 AM


All times are GMT -4. The time now is 12:54 PM.


MobileRead.com is a privately owned, operated and funded community.