Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Marshaling unicode WDDX

Reply
Thread Tools

Marshaling unicode WDDX

 
 
isthar
Guest
Posts: n/a
 
      01-05-2006
Hi !
i am trying to serialise object which contains some unicode objects
but looks like there is no way to do it.

File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/
_xmlplus/marshal/generic.py", line 92, in _marshal
return getattr(self, meth)(value, dict)
AttributeError: WDDXMarshaller instance has no attribute 'm_unicode'

WDDX is perfect for me for exchange between python and php application.
but maybe there is a better way to do it.


Any clue?

Thanks in advance.

 
Reply With Quote
 
 
 
 
Tim Arnold
Guest
Posts: n/a
 
      01-05-2006

"isthar" <> wrote in message
news: oups.com...
> Hi !
> i am trying to serialise object which contains some unicode objects
> but looks like there is no way to do it.
>


hi, I'm sure you'll get better answers for the unicode part of your problem
(I'd start with a look at the codecs module), but I wanted you to know that
I'm using the wddx connection between Python and PHP with no problem. Here's
the python code that writes a fairly complex data structure to the wddx
file:

def writeDocReport(self):
from xml.marshal import wddx
fileName = '%s/%s.doc.wddx' % (os.path.join(adsWeb,'jobs','wddx'),
self.name)
tmpFile = open(fileName,'wb')
tmpFile.write(wddx.dumps(self.getDocData()))
tmpFile.close()

and the PHP:

function getInputData($){
$file = "wddx/$prodName.wddx";

if (!is_file($file)) {
exit("<h1>Report is not available for $prodName</h1>");
}

$output = wddx_deserialize(file_get_contents($file));


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Guest
Posts: n/a
 
      01-05-2006
isthar wrote:
> WDDX is perfect for me for exchange between python and php application.
> but maybe there is a better way to do it.


It appears that Unicode objects where forgotten in the WDDX
implementation. I suggest to define the following classes:

class UWDDXMarshaller(xml.marshal.wddx.WDDXMarshaller):
def m_unicode(self, data, dict):
return self.m_string(data.encode("utf-8"), dict)

class UWDDXUnmarshaller(xml.marshal.wddx.WDDXUnmarshalle r):
def um_end_string(self, name):
ds = self.data_stack
ds[-1] = u"".join(ds[-1])
self.accumulating_chars = 0

The m_unicode part should get integrated into PyXML;
the um_end_string should probably return ASCII strings
if possible, else Unicode strings.

Regards,
Martin
 
Reply With Quote
 
isthar
Guest
Posts: n/a
 
      01-10-2006
Ok. but how I suppose to use them. I am currently using marshaller
indirectly via wddx.dump().

Anyway, thanks

 
Reply With Quote
 
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Guest
Posts: n/a
 
      01-10-2006
isthar wrote:
> Ok. but how I suppose to use them. I am currently using marshaller
> indirectly via wddx.dump().


Do UWDDXMarshaller().dump()

Regards,
Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
serialize wddx data in asp.net SV ASP .Net 4 06-25-2008 07:34 AM
wddx problem with entities Tim Arnold Python 1 06-09-2006 12:53 PM
WDDX or call of an url Alexander Widera ASP .Net 0 04-18-2005 03:41 PM
WDDX? Chris Morris Ruby 1 05-21-2004 09:15 AM
Working with XML WDDX Packets using VB.Net Fraser Dickson ASP .Net 0 01-09-2004 10:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57