[Zope] External script generates xml - how to turn it into an xml file object

Andy Bulka abulka@netspace.net.au
Sun, 9 Sep 2001 09:33:41 +1000


>  > I have an external script that generates an xml string - how do I
>  > turn that xml text into an zope xml file object ?
> What do you mean by an "zope xml file object"?
Yes, a file object with "content_type='text/xml'"

> it should make no problems at all when the "file" parameter
> of "manage_addFile" is a string containing "<" or ">".
Ok, that's promising.  All I have to do is get the xml string into zope -
and that's the problem.  The trouble is, xml returned by external scripts
doesn't arrive successfully into zope.  It seems that any tags in the string
returned by my external python method are stripped out by zope!!  Something
to do with xml-rpc, no doubt?

e.g the following external method

def ParseDummy2():
    return 'Hi <fred>from the external method</fred>'

will actually return
           'Hi from the external method'  (note the <fred> tags are
missing.)

Even if my external method encodes the < and > symbols, using, say
    s = sub('<','&lt;',s)
    s = sub('>','&gt;',s)
there is no easy way to un-substitute inside zope since the re module and
sub function is not available inside zope (security etc. issues).  Further,
there are some some occurences of '&lt;' in my string that I want to keep,
since these occurences are actual valid content (as opposed to being part of
a tag).

Perhaps, ideally there would be a pair of encode/decode methods available to
both python and zope that would deeply encode/decode the xml string returned
by my external method so that it bypasses all these problems?

-Andy