gwu-libraries / launchpad

A django based system that provides a stable URL for every item in the library's catalog. Various discovery services will link to these URLs. The page for each item will in turn link out to various other resources that provide methods for accessing the content of the items.
MIT License
15 stars 9 forks source link

unicode error on isbns with openurl data #217

Closed dchud closed 12 years ago

dchud commented 12 years ago

This happens regularly. An example stacktrace, on /isbn/041516947X. Note the u'aulast': [u'Pappe\u0301'] in the openurl querydict:

Traceback (most recent call last):

 File "/launchpad/release_m8_002/launchpad/ENV/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/launchpad/release_m8_002/launchpad/lp/ui/views.py", line 154, in isbn
   openurl = _openurl_dict(request.GET)

 File "/launchpad/release_m8_002/launchpad/lp/ui/views.py", line 33, in _openurl_dict
   d['query_string_encoded'] = urllib.urlencode(params)

 File "/usr/lib/python2.6/urllib.py", line 1267, in urlencode
   v = quote_plus(str(v))

UnicodeEncodeError: 'ascii' codec can't encode character u'\u0301' in position 5: ordinal not in range(128)

<WSGIRequest
path:/isbn/041516947X,
GET:<QueryDict: {u'rft_val_fmt': [u'info:ofi/fmt:kev:mtx:book'], u'isbn': [u'9780203003763'], u'req_dat': [u'<sessionid>0</sessionid>'], u'rft.title': [u'The Israel Palestine question'], u'pid': [u'<accession number>51673661</accession number><fssessid>0</fssessid>'], u'rft.date': [u'1999'], u'rfe_dat': [u'<accessionnumber>51673661</accessionnumber>'], u'id': [u'doi:'], u'aulast': [u'Pappe\u0301'], u'title': [u'The Israel Palestine question'], u'rft.place': [u'London ;;New York :'], u'rft.isbn': [u'9780203003763'], u'rft_id': [u'info:oclcnum/51673661', u'urn:ISBN:9780203003763'], u'sid': [u'FirstSearch:WorldCat'], u'url_ver': [u'Z39.88-2004'], u'date': [u'1999'], u'rfr_id': [u'info:sid/firstsearch.oclc.org:WorldCat'], u'rft.pub': [u'Routledge,'], u'rft.aulast': [u'Pappe\u0301'], u'rft.aufirst': [u'Ilan'], u'rft.genre': [u'unknown'], u'aufirst': [u'Ilan']}>,
POST:<QueryDict: {}>,
COOKIES:{'__utma': '94885515.1886328202.1347560930.1348264335.1348521815.14',
'__utmc': '154768805',
'__utmz': '94885515.1348264335.13.3.utmcsr=worldcat.org|utmccn=(referral)|utmcmd=referral|utmcct=/title/managers-balancing-act/oclc/42328711'},
META:{'CSRF_COOKIE': 'QqBSzZVxdP3edhXwbTCIeoW5u2Ug959c',
'DOCUMENT_ROOT': '/var/www',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_COOKIE': '__utma=55537597.1641502178.1347546969.1348243035.1348247455.8; __utmz=55537597.1348243035.7.3.utmcsr=library.gwu.edu|utmccn=(referral)|utmcmd=referral|utmcct=/; __utma=154768805.891507107.1347546983.1348520987.1348584679.28; __utmz=154768805.1348172942.20.2.utmcsr=uz4ug4lz9g.search.serialssolutions.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utma=94885515.1886328202.1347560930.1348264335.1348521815.14; __utmz=94885515.1348264335.13.3.utmcsr=worldcat.org|utmccn=(referral)|utmcmd=referral|utmcct=/title/managers-balancing-act/oclc/42328711; __utmc=154768805',
'HTTP_HOST': 'findit.library.gwu.edu',
'HTTP_REFERER': 'http://findit.library.gwu.edu/go?sid=FirstSearch%3AWorldCat&isbn=9780203003763&title=The+Israel+Palestine+question&date=1999&aulast=Pappe%CC%81&aufirst=Ilan&id=doi%3A&pid=%3Caccession+number%3E51673661%3C%2Faccession+number%3E%3Cfssessid%3E0%3C%2Ffssessid%3E&url_ver=Z39.88-2004&rfr_id=info%3Asid%2Ffirstsearch.oclc.org%3AWorldCat&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&req_dat=%3Csessionid%3E0%3C%2Fsessionid%3E&rfe_dat=%3Caccessionnumber%3E51673661%3C%2Faccessionnumber%3E&rft_id=info%3Aoclcnum%2F51673661&rft_id=urn%3AISBN%3A9780203003763&rft.aulast=Pappe%CC%81&rft.aufirst=Ilan&rft.title=The+Israel+Palestine+question&rft.date=1999&rft.isbn=9780203003763&rft.place=London+%3B%3BNew+York+%3A&rft.pub=Routledge%2C&rft.genre=unknown',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 5.1; rv:10.0.4) Gecko/20100101 Firefox/10.0.4',
'PATH': '/usr/local/bin:/usr/bin:/bin',
'PATH_INFO': u'/isbn/041516947X',
'PATH_TRANSLATED': '/launchpad/release_m8_002/launchpad/lp/lp/wsgi.py/isbn/041516947X',
'QUERY_STRING': 'sid=FirstSearch%3AWorldCat&isbn=9780203003763&title=The+Israel+Palestine+question&date=1999&aulast=Pappe%CC%81&aufirst=Ilan&id=doi%3A&pid=%3Caccession+number%3E51673661%3C%2Faccession+number%3E%3Cfssessid%3E0%3C%2Ffssessid%3E&url_ver=Z39.88-2004&rfr_id=info%3Asid%2Ffirstsearch.oclc.org%3AWorldCat&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&req_dat=%3Csessionid%3E0%3C%2Fsessionid%3E&rfe_dat=%3Caccessionnumber%3E51673661%3C%2Faccessionnumber%3E&rft_id=info%3Aoclcnum%2F51673661&rft_id=urn%3AISBN%3A9780203003763&rft.aulast=Pappe%CC%81&rft.aufirst=Ilan&rft.title=The+Israel+Palestine+question&rft.date=1999&rft.isbn=9780203003763&rft.place=London+%3B%3BNew+York+%3A&rft.pub=Routledge%2C&rft.genre=unknown',
'REMOTE_ADDR': '128.164.214.79',
'REMOTE_PORT': '3959',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/isbn/041516947X?sid=FirstSearch%3AWorldCat&isbn=9780203003763&title=The+Israel+Palestine+question&date=1999&aulast=Pappe%CC%81&aufirst=Ilan&id=doi%3A&pid=%3Caccession+number%3E51673661%3C%2Faccession+number%3E%3Cfssessid%3E0%3C%2Ffssessid%3E&url_ver=Z39.88-2004&rfr_id=info%3Asid%2Ffirstsearch.oclc.org%3AWorldCat&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&req_dat=%3Csessionid%3E0%3C%2Fsessionid%3E&rfe_dat=%3Caccessionnumber%3E51673661%3C%2Faccessionnumber%3E&rft_id=info%3Aoclcnum%2F51673661&rft_id=urn%3AISBN%3A9780203003763&rft.aulast=Pappe%CC%81&rft.aufirst=Ilan&rft.title=The+Israel+Palestine+question&rft.date=1999&rft.isbn=9780203003763&rft.place=London+%3B%3BNew+York+%3A&rft.pub=Routledge%2C&rft.genre=unknown',
'SCRIPT_FILENAME': '/launchpad/release_m8_002/launchpad/lp/lp/wsgi.py',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '192.245.136.98',
'SERVER_ADMIN': 'zut@gwu.edu',
'SERVER_NAME': 'findit.library.gwu.edu',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.14 (Ubuntu) Server at findit.library.gwu.edu Port 80</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.14 (Ubuntu)',
'force-proxy-request-1.0': '1',
'mod_wsgi.application_group': 'findit.library.gwu.edu|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': 'findit.library.gwu.edu',
'mod_wsgi.reload_mechanism': '1',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (2, 8),
'proxy-nokeepalive': '1',
'wsgi.errors': <mod_wsgi.Log object at 0x7f4b08ef8ea0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f4b09254f30>,
'wsgi.input': <mod_wsgi.Input object at 0x7f4b08e342f0>,
'wsgi.multiprocess': True,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>

See also:

joshuago78 commented 12 years ago

This is fixed with the latest code (not yet deployed to production)

joshuago78 commented 12 years ago

I will go ahead and do a new deployment now