2012-03-10 15 views
5

में कोई विशेषता 'str' नहीं है, मैं हमारी परियोजना में डब्लूएसडीएल के लिए सूड क्लाइंट का उपयोग कर रहा हूं।विशेषताइंटर: 'noneType' ऑब्जेक्ट में suds

मेरे पास यह कोड है।

sudsclient = sudsClient(settings.WSDL_URL) 
values = { 
            "MerchantCode": settings.YP_MERCHANT_CODE, 
            "MerchantReference": str(reference_id), 
            "TransactionType":settings.YP_TRANSACTION_TYPE, 
            "Amount":int(charged), 
            "CurrencyCode":client.currency, 
            "CardHolderName":str(form.cleaned_data['name_on_card']), 
            "CardNumber": str(form.cleaned_data['card_number']), 
            "ExpiryMonth":int(form.cleaned_data['exp_month']), 
            "ExpiryYear":int(form.cleaned_data['exp_year']), 
            "CardID":0, 
            "CardSecurityCode":str(form.cleaned_data['security_code']), 
            "CustomerAccountNumber":"", 
            "BillNumber":0, 
            "CardHolderEmail":str(form.cleaned_data['email']), 
            "ClientIPAddress":get_ip, 
            "Notes":"OK", 
              } 
response = sudsclient.service.OnlineTransaction(**values) 

जब मैं अपने कार्यक्रम मैं यह त्रुटि आई चलाएँ: मुझे यकीन है कि अपने स्थानीय और परीक्षण में मेरे कोड एक ही हैं हूँ

Exception Type: AttributeError 
Exception Value:  
'NoneType' object has no attribute 'str' 
Exception Location: /usr/local/lib/python2.7/dist-packages/suds/sax/document.py in str, line 48 

मुझे लगता है कि समस्या suds में है, लेकिन मुझे इसका समाधान करने के बारे में कोई जानकारी नहीं है।

क्या कोई मेरे मामले में मेरी मदद कर सकता है? पहले से धन्यवाद ..

Environment: 

Request Method: GET 
Request URL: http://127.0.0.1:8000/1/book/save/?csrfmiddlewaretoken=05e5bdb542c3be7515b87e8160c347a0&check_in=2012-04-24&check_out=2012-04-25&no_of_nights=1&quantity=1&product=4&price=900.0&chargedMasterCard=180.0&chargedVisa=90.0&totalcostMasterCard=720.0&totalcostVisa=810.0&totalcost=900.0&charged=10.0&price_rate=1000.0&old_totalcost=1000.0&discount_charged=100.0&first_name=dsnmbmh&last_name=jhbjhb&email=jdlabandero%40agile.com.ph&contact=657879&address=gjkj&no_of_adult=1&no_of_kid=0&memo=&card_type=MasterCard&card_number=40000234234210&security_code=788&name_on_card=ghjk&exp_month=1&exp_year=2012 

Django Version: 1.3.1 
Python Version: 2.7.1 
Installed Applications: 
['admin_tools', 
'admin_tools.theming', 
'admin_tools.menu', 
'admin_tools.dashboard', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.humanize', 
'django.contrib.admin', 
'surebooked.booking', 
'surebooked.api', 
'surebooked.account_app', 
'surebooked.client_app', 
'surebooked.product_app', 
'surebooked.report_app', 
'debug_toolbar', 
'billing', 
'south', 
'paypal.standard.ipn', 
'django_extensions', 
'cms', 
'menus', 
'mptt', 
'south', 
'cms.plugins.text', 
'cms.plugins.picture', 
'cms.plugins.link', 
'cms.plugins.file', 
'cms.plugins.snippet', 
'cms.plugins.googlemap', 
'sekizai', 
'django.contrib.admin', 
'filer', 
'sorl.thumbnail', 
'easy_thumbnails', 
'cmsplugin_filer_file', 
'cmsplugin_filer_folder', 
'cmsplugin_filer_image', 
'cmsplugin_filer_teaser', 
'cmsplugin_filer_video', 
'media_tree', 
'django_cron'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'debug_toolbar.middleware.DebugToolbarMiddleware', 
'media_tree.middleware.SessionPostMiddleware', 
'cms.middleware.page.CurrentPageMiddleware', 
'cms.middleware.user.CurrentUserMiddleware', 
'cms.middleware.toolbar.ToolbarMiddleware') 


    Traceback: 
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 
     111.       response = callback(request, *callback_args, **callback_kwargs) 
    File "/home/agileone/workspace/surebooked/surebooked/../surebooked/booking/views.py" in booking_save_page 
     752.        response = sudsclient.service.OnlineTransaction(**values) 
    File "/usr/local/lib/python2.7/dist-packages/suds/client.py" in __call__ 
     542.    return client.invoke(args, kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/suds/client.py" in invoke 
     595.   soapenv = binding.get_message(self.method, args, kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/suds/bindings/binding.py" in get_message 
     120.   content = self.bodycontent(method, args, kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/suds/bindings/document.py" in bodycontent 
     63.    p = self.mkparam(method, pd, value) 
    File "/usr/local/lib/python2.7/dist-packages/suds/bindings/document.py" in mkparam 
     105.    return Binding.mkparam(self, method, pdef, object) 
    File "/usr/local/lib/python2.7/dist-packages/suds/bindings/binding.py" in mkparam 
     287.   return marshaller.process(content) 
    File "/usr/local/lib/python2.7/dist-packages/suds/mx/core.py" in process 
     62.    self.append(document, content) 
    File "/usr/local/lib/python2.7/dist-packages/suds/mx/core.py" in append 
     73.   log.debug('appending parent:\n%s\ncontent:\n%s', parent, content) 
    File "/usr/lib/python2.7/logging/__init__.py" in debug 
     1120.    self._log(DEBUG, msg, args, **kwargs) 
    File "/usr/lib/python2.7/logging/__init__.py" in _log 
     1250.   self.handle(record) 
    File "/usr/lib/python2.7/logging/__init__.py" in handle 
     1260.    self.callHandlers(record) 
    File "/usr/lib/python2.7/logging/__init__.py" in callHandlers 
     1300.      hdlr.handle(record) 
    File "/usr/lib/python2.7/logging/__init__.py" in handle 
     744.     self.emit(record) 
    File "/home/agileone/workspace/surebooked/surebooked/.ve/src/django-debug-toolbar/debug_toolbar/panels/logger.py" in emit 
     51.    'message': record.getMessage(), 
    File "/usr/lib/python2.7/logging/__init__.py" in getMessage 
     328.    msg = msg % self.args 
    File "/usr/local/lib/python2.7/dist-packages/suds/sax/document.py" in __str__ 
     58.   return unicode(self).encode('utf-8') 
    File "/usr/local/lib/python2.7/dist-packages/suds/sax/document.py" in __unicode__ 
     61.   return self.str() 
    File "/usr/local/lib/python2.7/dist-packages/suds/sax/document.py" in str 
     48.   s.append(self.root().str()) 

    Exception Type: AttributeError at /1/book/save/ 
    Exception Value: 'NoneType' object has no attribute 'str' 

मुझे नहीं पता really2x मैं क्यों यह त्रुटि हुई। अब मुझे अपने स्थानीय और मेरे उत्पादन में एक ही त्रुटि मिली है। बीटीडब्ल्यू, जब मैं कोड को अलग करता हूं और चलाने की कोशिश करता हूं। यह ठीक चलाता है।

sudstest.py

#!/usr/bin/env python 
import os 
from suds.client import Client as abo 

WSDL = 'DirectConnect.production.wsdl' 

#def test_api(): 
url = 'file://' + os.path.join(os.path.abspath(os.path.dirname(__file__)), WSDL) 
print url 
client = abo(url) 

data = { 
    'MerchantCode': 'HELLO', 
    'MerchantReference': '3252', 
    'TransactionType': 20, 
    'Amount': 10, 
    'CurrencyCode': 'USD', 
    'CardHolderName': 'RAUL O REVECHE', 
    'CardNumber': 4005550000000001, 
    'ExpiryMonth': 5, 
    'ExpiryYear': 2013, 
    'CardID': 0, 
    'CardSecurityCode': 400, 
    'CustomerAccountNumber': '', 
    'BillNumber': 0, 
    'CardHolderEmail': '[email protected]', 
    'ClientIPAddress': 'http://127.0.0.1:8000/', 
    'Notes': 'This is test', 
} 

print data 
result = client.service.OnlineTransaction(**data) 
print result.ResponseDescription 
+0

पूर्ण ट्रैस बैक कृपया आप का उपयोग डीबग टूलबार के में विकास संस्करण का उपयोग कर सकते हैं। – jpic

+0

अब मेरे पास स्थानीय और उत्पादन में एक ही त्रुटि है। – gadss

उत्तर

2

अपवाद suds.sax.Document में निम्नलिखित के रूप में, self.root द्वारा लौटाए गए कोई भी मूल्य द्वारा caued है,

def root(self): 
    if len(self.children): 
     return self.children[0] 
    else: 
     return None 

तो यह कमी की वजह से लगता है कुछ डेटा फ़ील्ड। परीक्षण सर्वर पर भरने वाले सटीक डेटा को दोबारा चलाएं, स्थानीय मशीन पर फिर से मदद मिल सकती है। यह सुनिश्चित करने के लिए कि वे आपकी स्थानीय सेटिंग्स के समान हैं, परीक्षण सर्वर पर Django सेटिंग्स भी देखें।

+1

उत्तर के लिए धन्यवाद okm ... मैं अपनी सेटिंग्स की जांच करने की कोशिश करता हूं लेकिन कोई समस्या नहीं है ... – gadss

0

मुझे यह समस्या हमारे परीक्षण सर्वर में मिली है, आईपी पता डब्लूएसडीएल सर्वर द्वारा अवरुद्ध है, इसलिए प्रक्रिया करते समय WSDL सर्वर परीक्षण सर्वर में एक त्रुटि लौटाता है।

0

मुझे यह बग गायब करने के लिए मेरी सेटिंग्स में INTERNAL_IPS को टिप्पणी करना पड़ा। बहुत कम समझ में आता है, लेकिन मुझे उम्मीद है कि यह किसी और की मदद करेगा। =)

+0

हाय बाहू उत्तर के लिए धन्यवाद, मेरे पास मेरी सेटिंग्स में INTERNAL_IPS नहीं है। – gadss

+0

अपनी टूलबार को अक्षम करने का प्रयास करें। अंधेरे में गोली मार दी; लेकिन मेरी INTERNAL_IPS सेटिंग जिसे मैं अक्षम करना था django-debug-toolbar के लिए था, तो हो सकता है कि यह संबंधित हो। मेरे पास एक ही स्थिति थी, स्टैंडअलोन पायथन ठीक चला गया, लेकिन यह मेरे ऐप के अंदर उड़ा दिया ... उम्मीद है कि यह मदद करता है। – bahoo

12

बग सूड में है। @okm करीब था, लेकिन समस्या वास्तव में Document.__str__ में है। हालांकि बग को केवल django-debug-toolbar का उपयोग करते समय उजागर किया जाता है, क्योंकि लॉगिंग पैनल लॉग इन किए गए सभी संदेशों को दिखाता है। यह सूड बग ट्रिगर करता है। https://github.com/bradleyayers/suds-htj

संपादित करें::

मुझे लगता है कि इससे समस्या हल हो झाग का एक समझौता संस्करण बना लिया है मेरे पैच अब https://github.com/htj/suds-htj में विलय कर दिया गया है - कि भंडार का उपयोग करने के बजाय

+0

धन्यवाद, ऐप इंजन पर चलने के लिए इस फिक्स की भी आवश्यकता थी। चीयर्स! –

+3

मुझे लगता है कि नवीनतम एसयूडीएस यहां बनाए रखा गया है: https://bitbucket.org/jurko/suds 'pip इंस्टॉल suds-jurko' – benjaoming

+0

@ bradley.ayers मुझे Django कस्टम प्रबंधन कमांड के साथ एक ही समस्या का सामना करना पड़ रहा है। कोई विचार? – Conans

0

@ bradley.ayers सही है । यह समस्या सूड पुस्तकालय में है। मैं अपने अजवाइन कार्य में सूड == 0.4 का उपयोग कर रहा हूं।

कामकाज: जब मैंने सेलेरीड प्रक्रिया 'लॉग स्तर को डीईबीयूजी से वापस आईएनएफओ में स्विच किया तो मेरे लिए काम करना शुरू कर दिया।

2

@ bradley.ayers कहते हैं, समस्या सूड लाइब्रेरी (जो मर चुकी है) में है।संबंधित कोड के आसपास एक कोशिश पकड़ बयान जोड़कर https://github.com/htj/suds-htj

हालांकि, इस मुद्दे को डिबग टूलबार (> 0.9.4) के बाद के संस्करणों में fixed कर दिया गया है: आप कांटा वह पता चलता है का उपयोग कर सकते हैं।

pip install django-debug-toolbar==dev 

या या बस बंदर-पैच कोशिश पकड़ अपने आप को कहीं ब्लॉक अपने मॉड्यूल init फाइल में:

import debug_toolbar.panels.logger 

original_emit = debug_toolbar.panels.logger.ThreadTrackingHandler.emit 
def emit(self, record): 
    try: 
     original_emit(self, record) 
    except: 
     pass 
debug_toolbar.panels.logger.ThreadTrackingHandler.emit = emit 
संबंधित मुद्दे

 संबंधित मुद्दे