mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Fixing unicode issues in eve_api and eve_proxy. Shouldn't blow its guts on the russian alliances
This commit is contained in:
@@ -79,10 +79,9 @@ class EVEPlayerCorporationManager(models.Manager):
|
||||
"""
|
||||
corp_doc = CachedDocument.objects.api_query('/corp/CorporationSheet.xml.aspx',
|
||||
params={'corporationID': id})
|
||||
corp_dat = corp_doc.body.decode("utf-8", "replace")
|
||||
|
||||
# Convert incoming data to UTF-8.
|
||||
dom = minidom.parseString(corp_dat)
|
||||
dom = minidom.parseString(corp_doc.body.encode('utf-8'))
|
||||
|
||||
error_node = dom.getElementsByTagName('error')
|
||||
|
||||
@@ -93,4 +92,4 @@ class EVEPlayerCorporationManager(models.Manager):
|
||||
raise InvalidCorpID(id)
|
||||
|
||||
return dom
|
||||
|
||||
|
||||
|
||||
@@ -27,14 +27,12 @@ class CachedDocumentManager(models.Manager):
|
||||
# Retrieve the response from the server.
|
||||
response = conn.getresponse()
|
||||
# Save the response (an XML document) to the CachedDocument.
|
||||
cached_doc.body = response.read()
|
||||
|
||||
cached_doc.body = unicode(response.read(), 'utf-8')
|
||||
|
||||
try:
|
||||
# Parse the response via minidom
|
||||
dom = minidom.parseString(cached_doc.body)
|
||||
dom = minidom.parseString(cached_doc.body.encode('utf-8'))
|
||||
except xml.parsers.expat.ExpatError:
|
||||
print "XML Parser Error:"
|
||||
print cached_doc.body
|
||||
return
|
||||
|
||||
# Set the CachedDocument's time_retrieved and cached_until times based
|
||||
@@ -97,7 +95,7 @@ class CachedDocumentManager(models.Manager):
|
||||
else:
|
||||
# Parse the document here since it was retrieved from the
|
||||
# database cache instead of queried for.
|
||||
dom = minidom.parseString(cached_doc.body)
|
||||
dom = minidom.parseString(cached_doc.body.encode('utf-8'))
|
||||
|
||||
# Check for the presence errors. Only check the bare minimum,
|
||||
# generic stuff that applies to most or all queries. User-level code
|
||||
@@ -123,4 +121,4 @@ class CachedDocument(models.Model):
|
||||
cached_until = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
# The custom manager handles the querying.
|
||||
objects = CachedDocumentManager()
|
||||
objects = CachedDocumentManager()
|
||||
|
||||
Reference in New Issue
Block a user