Ticket #283 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

Flex - pyAmf - Django objects - channel error with strings containing accents (é,è,.....)

Reported by: datafunk Owned by: nick
Priority: major Milestone: 0.4
Component: Utility Version: 0.3.1
Keywords: Django, Remote Object Cc:

Description (last modified by thijs) (diff)

In attachement of this ticket, an example a basic test for working with flex (with remote object) and django. Based on the chinese example and some flex django stuff from Aral Balkan.

When testing this application on the behaviour with all characters (including the ones used in the french language) , I've got an Channel call failed.

Installing this example, add this to the properties of your flex project. (Flex Compiler)

-locale en_US -services "../_config/services-config.xml"

Attachments

20080512_djangoswf.zip (0.8 MB) - added by datafunk 7 months ago.
Zip file containing example code (src folder = flex code)
Picture 2.png (56.7 KB) - added by datafunk 7 months ago.
Screenshot of django Admin
Picture 3.png (45.8 KB) - added by datafunk 7 months ago.
Flex giving an error.
Picture 1.png (21.3 KB) - added by datafunk 7 months ago.
Flex giving results from db through django gateway
amfDjango.db (36.0 KB) - added by thijs 7 months ago.
test sqlite database (with a user and department called Néèm?sf?tiØ)
djangoswf.mxml (1.4 KB) - added by thijs 7 months ago.
modified MXML sample
request-283.amf (223 bytes) - added by thijs 7 months ago.
amf request charles dump
response-283.amf (1.6 KB) - added by thijs 7 months ago.
amf response charles dump
services-config.xml (424 bytes) - added by thijs 7 months ago.
remoting config for flex
remoting-config.xml (404 bytes) - added by thijs 7 months ago.
second remoting config for flex
djangoswf.swf (231.9 KB) - added by thijs 7 months ago.
Adding updated version of swf
error-283.html (47.5 KB) - added by thijs 7 months ago.
UnicodeDecodeError? at /djangoswf/gateway/
unicode-repr.diff (402 bytes) - added by nick 7 months ago.
Show %r for repr'ing flex.messaging.AbstractMessage
patch-works.png (6.1 KB) - added by thijs 7 months ago.

Change History

Changed 7 months ago by datafunk

Zip file containing example code (src folder = flex code)

Changed 7 months ago by datafunk

Screenshot of django Admin

Changed 7 months ago by datafunk

Flex giving an error.

Changed 7 months ago by datafunk

Flex giving results from db through django gateway

follow-up: ↓ 4   Changed 7 months ago by thijs

I setup your example but receiving this error:

['Traceback (most recent call last):\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 145, in __call__\n    return self._getBody(amf_request, ro_request, **kwargs)\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 99, in _getBody\n    return self._processRemotingMessage(amf_request, ro_request, **kwargs)\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 128, in _processRemotingMessage\n    ro_response.body = self.gateway.callServiceRequest(service_request, *ro_request.body, **kwargs)\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/__init__.py", line 474, in callServiceRequest\n    return service_request(*args)\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/__init__.py", line 211, in __call__\n    return self.service(self.method, args)\n', '  File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/__init__.py", line 113, in __call__\n    return func(*params)\n', '  File "/Users/SpaceBoy/__sites_django/djangoswf/../djangoswf/amfgateway.py", line 8, in getDepAllUsers\n    dep=Department.objects.get(id=depID)\n', '  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get\n    return self.get_query_set().get(*args, **kwargs)\n', '  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get\n    raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name\n', 'DoesNotExist: Department matching query does not exist.\n']

I changed the settings to a sqlite setup because I couldn't find the sql schema file. Could you supply a sqlite3 .db containing all the data, including the accents that it crashes with?

follow-up: ↓ 3   Changed 7 months ago by thijs

  • description modified (diff)

What version are you using btw, 0.3.1?

in reply to: ↑ 2   Changed 7 months ago by datafunk

Replying to thijs:

What version are you using btw, 0.3.1?

Indeed, latest version 0.3.1

in reply to: ↑ 1 ; follow-up: ↓ 5   Changed 7 months ago by datafunk

Replying to thijs:

I setup your example but receiving this error: {{{ ['Traceback (most recent call last):\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 145, in call\n return self._getBody(amf_request, ro_request, **kwargs)\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 99, in _getBody\n return self._processRemotingMessage(amf_request, ro_request, **kwargs)\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 128, in _processRemotingMessage\n ro_response.body = self.gateway.callServiceRequest(service_request, *ro_request.body, **kwargs)\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/init.py", line 474, in callServiceRequest\n return service_request(*args)\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/init.py", line 211, in call\n return self.service(self.method, args)\n', ' File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/gateway/init.py", line 113, in call\n return func(*params)\n', ' File "/Users/SpaceBoy/sites_django/djangoswf/../djangoswf/amfgateway.py", line 8, in getDepAllUsers\n dep=Department.objects.get(id=depID)\n', ' File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get\n return self.get_query_set().get(*args, **kwargs)\n', ' File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get\n raise self.model.DoesNotExist?, "%s matching query does not exist." % self.model._meta.object_name\n', 'DoesNotExist?: Department matching query does not exist.\n'] }}} I changed the settings to a sqlite setup because I couldn't find the sql schema file. Could you supply a sqlite3 .db containing all the data, including the accents that it crashes with?

Never used sqlite before...when below doesn't work, I will try deliver a sqlite.db

But django generates automatically your database when running following command in the project folder (if settings are correct).

python manage.py syncdb

Any "accent" (don't know if that's correct english) is causing a problem, also the "umlauts".

in reply to: ↑ 4 ; follow-up: ↓ 7   Changed 7 months ago by thijs

Replying to datafunk:

Replying to thijs:

I changed the settings to a sqlite setup because I couldn't find the sql schema file. Could you supply a sqlite3 .db containing all the data, including the accents that it crashes with?

Never used sqlite before...when below doesn't work, I will try deliver a sqlite.db But django generates automatically your database when running following command in the project folder (if settings are correct). {{{ python manage.py syncdb }}} Any "accent" (don't know if that's correct english) is causing a problem, also the "umlauts".

I tried the syncdb command and created a .db but this one doesn't contain any records I assume. A simple sqlite.db or a .sql for mysql with the data included would be essential.

follow-up: ↓ 8   Changed 7 months ago by nick

What are the locale settings for your mysql db?

in reply to: ↑ 5 ; follow-up: ↓ 9   Changed 7 months ago by datafunk

Replying to thijs:

Replying to datafunk:

Replying to thijs:

I changed the settings to a sqlite setup because I couldn't find the sql schema file. Could you supply a sqlite3 .db containing all the data, including the accents that it crashes with?

Never used sqlite before...when below doesn't work, I will try deliver a sqlite.db But django generates automatically your database when running following command in the project folder (if settings are correct). {{{ python manage.py syncdb }}} Any "accent" (don't know if that's correct english) is causing a problem, also the "umlauts".

I tried the syncdb command and created a .db but this one doesn't contain any records I assume. A simple sqlite.db or a .sql for mysql with the data included would be essential.

Once synced the database and created a master account, you can enter some data through the django backend http://localhost:8000/admin/

First adding a departement, and then some users.

in reply to: ↑ 6   Changed 7 months ago by datafunk

Replying to nick:

What are the locale settings for your mysql db?

utf8_unicode_ci

Changed 7 months ago by thijs

test sqlite database (with a user and department called Néèm?sf?tiØ)

in reply to: ↑ 7   Changed 7 months ago by thijs

Replying to datafunk:

Once synced the database and created a master account, you can enter some data through the django backend http://localhost:8000/admin/ First adding a departement, and then some users.

Ok that worked, see attached database. I modified the mxml a little and changed the call to userService.getAllDepartments.send(), see attached mxml and services-config.xml. I can reproduce the bug and attached the Charles request/response files, showing this error:

['Traceback (most recent call last):\n', '  
File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 145, in __call__\n    return self._getBody(amf_request, ro_request, **kwargs)\n', '  
File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 97, in _getBody\n    return self._processCommandMessage(amf_request, ro_request, **kwargs)\n', '  
File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/amf3.py", line 113, in _processCommandMessage\n    
raise ServerCallFailed, "Unknown command operation %s" % ro_request.operation\n', 'ServerCallFailed: Unknown command operation 12\n']

Changed 7 months ago by thijs

modified MXML sample

Changed 7 months ago by thijs

amf request charles dump

Changed 7 months ago by thijs

amf response charles dump

Changed 7 months ago by thijs

remoting config for flex

Changed 7 months ago by thijs

second remoting config for flex

Changed 7 months ago by thijs

Adding updated version of swf

  Changed 7 months ago by thijs

  • owner changed from thijs to nick
  • component changed from Examples to AMF3

  Changed 7 months ago by thijs

Charles also showed this html error report generated by Django which exposes an additional error:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  81. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/__init__.py" in __repr__
  130. r += " " + repr(request) + "\n"
File "/Users/thijstriemstra/Sites/pyamf/pyamf/trunk/pyamf/remoting/__init__.py" in __repr__
  206. type(self).__name__)

  UnicodeDecodeError at /djangoswf/gateway/
  'ascii' codec can't decode byte 0xc3 in position 41: ordinal not in range(128)

Changed 7 months ago by thijs

UnicodeDecodeError? at /djangoswf/gateway/

Changed 7 months ago by nick

Show %r for repr'ing flex.messaging.AbstractMessage

  Changed 7 months ago by nick

  • owner changed from nick to datafunk
  • status changed from new to assigned
  • component changed from AMF3 to Utility

Okay I think found the, problem. First off, the pyamf encoders were handling unicode correctly. However, the encoder writes to its logger at various points of interest and this repr was causing pyamf to bork.

I have attached the patch which fixes this issue (at least for me).

Can you check?

Changed 7 months ago by thijs

  Changed 7 months ago by thijs

  • owner changed from datafunk to nick

Tested it with the patch and it's now working for me, assigning back to nick. This shows the string being displayed/returned correctly with Flex.

  Changed 7 months ago by nick

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r1375.

Note: See TracTickets for help on using tickets.