Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 错误+;不匹配的标记+;外派建筑商_Django_Python 2.7_E Commerce - Fatal编程技术网

Django 错误+;不匹配的标记+;外派建筑商

Django 错误+;不匹配的标记+;外派建筑商,django,python-2.7,e-commerce,Django,Python 2.7,E Commerce,我正在尝试通过Jim McGaw开始的Django电子商务。在阅读第五章的过程中,在引入google checkout选项后,我面临以下错误。有人能给我一些建议/可能的解决方案吗 代码片段如下所示 $ def get_checkout_url(request): redirect_url ='' req = _create_google_checkout_request(request) try: respons

我正在尝试通过Jim McGaw开始的Django电子商务。在阅读第五章的过程中,在引入google checkout选项后,我面临以下错误。有人能给我一些建议/可能的解决方案吗

代码片段如下所示

$ def get_checkout_url(request): redirect_url ='' req = _create_google_checkout_request(request) try: response_xml = urlopen(req).read() except HTTPError, err: raise err except URLError, err: raise err else: redirect_url = _parse_google_checkout_response(response_xml) return redirect_url $ def _parse_google_checkout_response(response_xml): redirect_url = "" print response_xml xml_doc = minidom.parseString(response_xml) # -- Breaks here -- # xml_doc = minidom.parse(response_xml) root = xml_doc.documentElement node = root.childNodes[1] if node.tagName == 'redirect-url': redirect_url = node.firstChild.data if node.tagName == 'error-message': raise RuntimeError(node.firstChild.data) return redirect_url $ def get_checkout_url(请求): 重定向\u url=“” 请求=\u创建\u谷歌\u签出\u请求(请求) 尝试: response_xml=urlopen(req).read() 除HTTPError外,错误: 提出错误 除了URLError,err: 提出错误 其他: 重定向\u url=\u解析\u谷歌\u签出\u响应(响应\u xml) 返回重定向url $def_解析_谷歌_签出_响应(响应\u xml): 重定向_url=“” 打印响应xml xml_doc=minidom.parseString(response_xml)#——在这里中断-- #xml\u doc=minidom.parse(响应\u xml) root=xml\u doc.documentElement node=root.childNodes[1] 如果node.tagName==“重定向url”: 重定向\u url=node.firstChild.data 如果node.tagName==“错误消息”: 引发运行时错误(node.firstChild.data) 返回重定向url 错误日志如下所示:

**Environment:** Django Version: 1.4.1 Python Version: 2.7.1 Traceback: File "/Users/username/work/pythonwork/djtrunk/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/Users/username/work/pythonwork/ecomstore/cart/views.py" in show_cart 19. checkout_url = checkout.get_checkout_url(request) File "/Users/username/work/pythonwork/ecomstore/checkout/checkout.py" in get_checkout_url 6. return google_checkout.get_checkout_url(request) File "/Users/username/work/pythonwork/ecomstore/checkout/google_checkout.py" in get_checkout_url 27. redirect_url = _parse_google_checkout_response(response_xml) File "/Users/username/work/pythonwork/ecomstore/checkout/google_checkout.py" in _parse_google_checkout_response 46. xml_doc = minidom.parseString(response_xml) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py" in parseString 1924. return expatbuilder.parseString(string) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py" in parseString 940. return builder.parseString(string) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py" in parseString 223. parser.Parse(string, True) Exception Type: ExpatError at /cart/ Exception Value: mismatched tag: line 1460, column 4 **环境:** Django版本:1.4.1 Python版本:2.7.1 回溯: get_响应中的文件“/Users/username/work/pythonwork/djtrunk/django/core/handlers/base.py” 111响应=回调(请求,*回调参数,**回调参数) show\u cart中的文件“/Users/username/work/pythonwork/ecomstore/cart/views.py” 19checkout\u url=checkout.get\u checkout\u url(请求) get\u checkout\u url中的文件“/Users/username/work/pythonwork/ecomstore/checkout/checkout.py” 6.返回google\u checkout.get\u checkout\u url(请求) get\u checkout\u url中的文件“/Users/username/work/pythonwork/ecomstore/checkout/google\u checkout.py” 27重定向\u url=\u解析\u谷歌\u签出\u响应(响应\u xml) 文件“/Users/username/work/pythonwork/ecomstore/checkout/google\u checkout.py”在\u parse\u google\u checkout\u响应中 46xml\u doc=minidom.parseString(响应\u xml) parseString中的文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py” 1924返回expatbuilder.parseString(字符串) parseString中的文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py” 940return builder.parseString(字符串) parseString中的文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py” 223parser.Parse(字符串,True) 异常类型:在/cart处发生错误/ 异常值:不匹配的标记:第1460行第4列
Hi Hari-我怀疑这可能是因为API返回的response_xml变量不再包含名为“redirect url”的节点。也许它已经被重命名,或者它已经被移动了。您是否有可能共享response_xml的(非敏感)内容?最近我和您处于相同的情况,并且收到了相同的错误。在与该书作者吉姆·麦高(Jim McGaw)合作后,我们解决了这个问题。您可能希望尝试在settings.py中重新键入商户id、商户密钥和结帐url的值。我希望这对你有帮助。Parker@poto谢谢我会试试的。@JimMcGaw将第二次浏览你的书,从这个周末开始,我将在点击谷歌结账时分享详细信息!谢谢你的帮助。