[XML-SIG] Marshalling

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Fri, 18 Dec 1998 09:13:59 -0500 (EST)


Paul Prescod writes:
> * why have a single class for marshalling and unmarshalling?

	My fuzzy argument for this was that I wanted the user to write
only a single subclass, not two of them. 

> * this stuff is a little weird: "m = self.__class__()" Could we put all
>of the mutable data in a separate class and avoid it? Maybe I'm just
>skittish about strange idioms...

	Probably data_stack shouldn't be an attribute of the class,
but be passed to each of the unmarshalling functions.  That would mean
that the Marshaller class would have no mutable attributes at all, and
the self.__class__ thing would be unnecessary.

> * Could m_unimplemented be called by default for unhandled classes?

	Good point; I'll clean that up, and also make the listing of
unmarshalling functions tidier.

> * Maybe string handling should be safer...i.e. control characters

	Shouldn't control characters, such as chr(9) or chr(7) be
fine?  The code already escapes <,&,>, and aren't those the only
characters to worry about?  

	Another potential problem is that on unmarshalling, the XML
parser may change newlines around inside your string.  If you care,
then you'd have to base64-encode all your strings.  I may add code to
check for Tim Bray's proposed attribute, xml:packed="base64" (or
whatever it is), and automatically decode it.

>User defined types issues:
> 1. What do we do about instances? I suggest looping over data-properties
>and saving them as named structs. The names should be unique URIs.

> 2. what do we do about built-in types (i.e. complex)? I suggest using
>copy_reg to deconstruct ... and using URI-named structs again.

	The generic code actually does complex numbers, but I see your 
point.  

> 3. pickle uses various magic methods: __reduce__, __getinitargs__,
>__getstate__. Should XML marshalling support some or all of that stuff?

 <sigh> Definitely, if it supports generic Python instances.  However, 
I'm less interested in reproducing pickle in XML than in providing a
base for supporting all the various DTDs that are popping up.

-- 
A.M. Kuchling			http://starship.skyport.net/crew/amk/
A wise man can do no better than to turn from the churches and look up through
the airy majesty of the wayside trees with exultation, with resignation, at
the unconquerable unimplicated sun.
    -- Llewelyn Powys, _The Pathetic Fallacy_