django - AttributeError: 'NoneType' object has no attribute 'str' in suds -


i using suds client wsdl in our project.

i have code .

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) 

when run program got error:

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 

i sure code in local , test same.

i think problem in suds, don't have idea on how solve it.

do can me in case? in advance ..

 environment:  request method: 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 @ /1/book/save/     exception value: 'nonetype' object has no attribute 'str' 

i really2x don't know why got error. got same error in local , production. btw, when separate code , try run. runs ok.

sudstest.py

#!/usr/bin/env python import os suds.client import client 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': 'development@yespayments.com.ph',     'clientipaddress': 'http://127.0.0.1:8000/',     'notes': 'this test', }  print data result = client.service.onlinetransaction(**data) print result.responsedescription 

the exception caued none value returned self.root, following in suds.sax.document,

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

so seems caused lacking data fields. replay exact data fill on test server, on local machine again might help. check django settings on test server make sure similar local settings.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -