Ticket #426 (closed defect: fixed)

Opened 14 months ago

Last modified 14 months ago

ElementTree serialized to ObjectProxy, not XML

Reported by: jhaislip Owned by: nick
Priority: critical Milestone: 0.4
Component: Remoting Version: 0.4
Keywords: ElementTree, ObjectProxy, XML Cc:
Fixed in revision: Branch:
Author:

Description (last modified by thijs) (diff)

I recently setup pyAMF with mod_python. I wrote test services that return the various datatypes of interest (DateTime, List, Bool, etc). I then accessed those services from a Flex application and saw that the serialization into Flex data types was working (Date, Array, Bool, etc). All of the data types I tested worked as they are supposed to except for one: ElementTree.

In my service, I have:

from pyamf.remoting.gateway.wsgi import WSGIGateway
import elementtree.ElementTree as ET

def getXML():
    root = Element("root")

    SubElement(root, "one")
    SubElement(root, "two")
    SubElement(root, "three")
    SubElement(root, "four")
    return root

# Expose our services:
services = {
    'service.getXML': getXML
}

GatewayController = WSGIGateway(services)

Here is the Flex:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                                horizontalAlign="center" verticalAlign="middle">
        
        <mx:RemoteObject id="remoteObj" endpoint="http://localhost:80/services" destination="service"
        result="displayResult(event)" fault="remoteFault(event)">
        </mx:RemoteObject>
        
        <mx:Button click="handleGetXML(event)" label="Get XML"/>
                
        
        <mx:Text id="result" width="100%" height="100%"/>

<mx:Script>
<![CDATA[
import mx.utils.ObjectUtil;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;


private function displayResult(re:ResultEvent): void {
    result.text = ObjectUtil.toString(re.result) + "\n";
}
private function remoteFault(fault:FaultEvent): void {
    result.text = ObjectUtil.toString(fault);
}
private function handleGetXML(evt:MouseEvent):void {
        remoteObj.getXML()
}
]]>
</mx:Script>

        
</mx:Application>

When I access the service from Flex, it returns an ObjectProxy and not an XML.

Change History

Changed 14 months ago by thijs

  • priority changed from major to critical
  • description modified (diff)
  • milestone changed from 0.5 to 0.4

Moving to milestone 0.4.

Changed 14 months ago by thijs

It was confirmed (on IRC) that this is working with 0.3.1 and a 0.4/trunk issue only.

Changed 14 months ago by nick

  • status changed from new to accepted

Changed 14 months ago by nick

  • keywords ElementTree, ObjectProxy, XML, review added; ElementTree ObjectProxy XML removed
  • owner changed from nick to thijs
  • status changed from accepted to assigned

I amended the xml lib initialisation code to check in order for all libraries available and to check for each type when encoding xml elements.

When decoding PyAMF will use the first implementation is comes across.

This is the order:

1. xml.etree.cElementTree 2. cElementTree 3. xml.etree.ElementTree 4. elementtree.ElementTree

Tests have been added to ensure that all libs are compatible.

Changed 14 months ago by thijs

  • owner changed from thijs to nick

The new method needs @since: 0.4 markup.

Changed 14 months ago by nick

  • owner changed from nick to thijs

Done.

Changed 14 months ago by thijs

  • keywords XML added; XML, review removed
  • owner changed from thijs to nick

If it works with the latest EchoTest, and passes the tests on feisley's buildslaves, then it can be merged.

Changed 14 months ago by nick

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

Checked EchoTest and slaves - all good.

I have merged to trunk in r1992 and to source:pyamf/branches/release-0.4 in r1993.

Note: See TracTickets for help on using tickets.