Marshaling unicode WDDX

Discussion in 'Python' started by isthar, Jan 5, 2006.

  1. isthar

    isthar Guest

    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.
    isthar, Jan 5, 2006
    #1
    1. Advertising

  2. isthar

    Tim Arnold Guest

    "isthar" <> wrote in message
    news:...
    > 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));
    Tim Arnold, Jan 5, 2006
    #2
    1. Advertising

  3. 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.WDDXUnmarshaller):
    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
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Jan 5, 2006
    #3
  4. isthar

    isthar Guest

    Ok. but how I suppose to use them. I am currently using marshaller
    indirectly via wddx.dump().

    Anyway, thanks :)
    isthar, Jan 10, 2006
    #4
  5. isthar wrote:
    > Ok. but how I suppose to use them. I am currently using marshaller
    > indirectly via wddx.dump().


    Do UWDDXMarshaller().dump()

    Regards,
    Martin
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Jan 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fraser Dickson

    Working with XML WDDX Packets using VB.Net

    Fraser Dickson, Jan 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,927
    Fraser Dickson
    Jan 9, 2004
  2. Alexander Widera

    WDDX or call of an url

    Alexander Widera, Apr 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    459
    Alexander Widera
    Apr 18, 2005
  3. Tim Arnold

    wddx problem with entities

    Tim Arnold, Jun 7, 2006, in forum: Python
    Replies:
    1
    Views:
    313
    Tim Arnold
    Jun 9, 2006
  4. SV
    Replies:
    4
    Views:
    517
  5. Chris Morris

    WDDX?

    Chris Morris, May 20, 2004, in forum: Ruby
    Replies:
    1
    Views:
    99
    NAKAMURA, Hiroshi
    May 21, 2004
Loading...

Share This Page