Jim McGaw による Beginning Django e-commerce に取り組もうとしています。Chapter-5 の作業中に、google-checkout オプションを導入した後、次のエラーに直面しています。誰か提案/可能な解決策を教えてもらえますか?
コードスニペットは次のとおりです。
$
def get_checkout_url (リクエスト):
リダイレクト URL =''
req = _create_google_checkout_request(リクエスト)
試す:
response_xml = urlopen(req).read()
HTTPError 以外、エラー:
エラーを上げる
URLError 以外、エラー:
エラーを上げる
そうしないと:
redirect_url = _parse_google_checkout_response(response_xml)
redirect_url を返す
$ def _parse_google_checkout_response(response_xml):
redirect_url = ""
response_xml を出力
xml_doc = minidom.parseString(response_xml) # -- ここで壊れます --
# xml_doc = minidom.parse(response_xml)
ルート = xml_doc.documentElement
ノード = root.childNodes[1]
node.tagName == 'リダイレクト URL' の場合:
redirect_url = node.firstChild.data
if node.tagName == 'エラーメッセージ':
RuntimeError(node.firstChild.data) を発生させます
redirect_url を返す
エラーログは次のとおりです。
**環境:** ジャンゴのバージョン: 1.4.1 Python バージョン: 2.7.1 トレースバック: get_response のファイル「/Users/username/work/pythonwork/djtrunk/django/core/handlers/base.py」 111. 応答 = コールバック(要求、*callback_args、**callback_kwargs) show_cart のファイル「/Users/username/work/pythonwork/ecomstore/cart/views.py」 19. checkout_url = checkout.get_checkout_url(リクエスト) get_checkout_url のファイル「/Users/username/work/pythonwork/ecomstore/checkout/checkout.py」 6. google_checkout.get_checkout_url(リクエスト) を返す get_checkout_url のファイル「/Users/username/work/pythonwork/ecomstore/checkout/google_checkout.py」 27. redirect_url = _parse_google_checkout_response(response_xml) _parse_google_checkout_response のファイル「/Users/username/work/pythonwork/ecomstore/checkout/google_checkout.py」 46. xml_doc = minidom.parseString(response_xml) parseString のファイル「/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py」 1924. return expatbuilder.parseString(string) parseString のファイル「/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py」 940. return builder.parseString(string) parseString のファイル「/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py」 223. parser.Parse(文字列, True) 例外タイプ: ExpatError at /cart/ 例外値: タグの不一致: 行 1460、列 4