포럼: Support Forum (Thread #16182)

Debug amf.RemotingService (2007-09-17 10:57 by arthur #32345)

I tried follow
http://djangoamf.sourceforge.jp/index.php?UserManual_en
and
http://djangoamf.sourceforge.jp/index.php?amf.RemotingService_en

However, I kept get

>>> service = amf.RemotingService('http://bsd6.tv:8000/gateway/', 'calculateService', 3);
>>> print service.save(2, 3);
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.4/site-packages/amf/__init__.py", line 255, in __call__
faultString=result.get('description', ''),
AttributeError: 'NoneType' object has no attribute 'get'

Can anybody give me some hints for debugging?
Thanks.

-- Arthur

RE: Debug amf.RemotingService (2007-09-23 18:33 by arthur #32443)

Dear Everyone,
Sorry to post again with more detail explanation--

I do the following steps but unfortunately kept getting error message,
would you please help me?
―――――――&#8211;
/www/Django# django-admin.py startproject calculate; cd calculate;
/www/Django/calculate# md example

― vi settings.py ―
#install applications
INSTALLED_APPS = (
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.sites’,
‘example’,
)

― vi /www/Django/calculate/example/views.py &#8211;
def calculate(request, arg1, arg2): #1
return arg1 + arg2
def calculate2(request, obj): #2
obj[’sum’] = obj[’arg1′] + obj[’arg2′]
return obj
def getCurrentDatetime(request): #3
import datetime.datetime
return datetime.now()
def getAllCustomers(request): #4
from example.models import Customer
return Customer.objects.all()
――――――――――――――――――――

――――― vi urls.py ―――――――――――――――-
from django.conf.urls.defaults import *
import amf.django

urlpatterns = patterns(”,
(r’^gateway/calculateService/(.*)’, ‘amf.django.views’, {’views’:'example.views’}), #1

(r’^gateway/timeService/whatTimeIsItNow’, ‘exampe.views.getCurrentDatetime’), #2
)

―――-test AMF in python ――――――――-
import amf;
service = amf.RemotingService(’http://localhost:8000/gateway/’, ‘calculateService’, 3);
print service.calculate(2, 3);

===> Then, I get the error:

Traceback (most recent call last):
File “”, line 1, in ?
File “/usr/local/lib/python2.4/site-packages/amf/__init__.py”, line 255, in __call__
faultString=result.get(’description’, ”),
AttributeError: ‘NoneType’ object has no attribute ‘get’
―&#8211;

Would you please give me some hints for debugging? Thanks a lots.

&#8211; Arthur
Reply to #32345

RE: Debug amf.RemotingService (2007-09-23 18:56 by otsuka #32444)

Hi Arthur,

What version of Django AMF do you use?
If you use the older one, please use the latest version.

The traceback message above shows that the fault response is returned from the server. So I guess that the traceback message is displayed in a console window which run the django development server. If true, could you post the serverside traceback?
Reply to #32443

RE: Debug amf.RemotingService (2007-10-31 00:23 by arthur #33074)

Thank you. After I installed newest version it works.
However, I found that
--- vi models.py -------------
from django.db import models

class Card(models.Model):
lastName = models.CharField(maxlength=20)
firstName = models.CharField(maxlength=20)
company = models.CharField(maxlength=50)
tel = models.CharField(maxlength=15)
email = models.EmailField(null=True)
zip = models.CharField(maxlength=8)
address = models.CharField(maxlength=200)
url = models.CharField(null=True, maxlength=250)
birthday = models.DateField(null=True)
portraitUrl = models.CharField(null=True, maxlength=250)
-------------------------

>>service = amf.RemotingService('http://bsd6.tv:8000/gateway/', 'addressBookService', 3);
>>print service.getCards()
I will get "HTTP Error 500: INTERNAL SERVER ERROR"

and in server side it said:
File "/usr/local/lib/python2.4/site-packages/amf/amf0.py", line 250, in write_long
output.write(struct.pack('L', long(socket.htonl(l))))
OverflowError: can't convert negative value to unsigned long

but if I mark out the last one in models.py, i.e.,
# portraitUrl = models.CharField(null=True, maxlength=250)
then,
>>print service.getCards() works
it returned:
{'tel': '2', 'zip': '', 'firstName': '2', 'url': None, 'lastName': '2', 'company': '2', 'id': 1, 'birthday': None, 'address': '', 'portrait': None, 'email': None, '_explicitType': 'addressbook.models.Card'}

Is there anything wrong in /usr/local/lib/python2.4/site-packages/amf/amf0.py"?
Thank you in advance.
Reply to #32444

RE: Debug amf.RemotingService (2007-11-01 11:06 by otsuka #33109)

> Is there anything wrong in /usr/local/lib/python2.4/site-packages/amf/amf0.py"?

Yes, it's a bug. I fixed it and released version 0.5.5.
Reply to #32345

RE: Debug amf.RemotingService (2007-11-02 13:37 by arthur #33139)

Thank you very much. After patched the newer version, it works perfectly.
Reply to #33109