Chris Withers wrote:
I suspect the following pattern needs to be changed:

         ostream = tempfile.NamedTemporaryFile(suffix='.xml')
         try:
             data = exportXML(connection, oid, ostream)
             ostream.flush()
             sub._importObjectFromFile(ostream.name, 0, 0)
         finally:
             ostream.close()

Yep, that looks like it. Either I'll make my first commit to Zope 2 ever :) or if you want to, you can change it to something like this:

import tempfile
import os

fname = 'import_export.xml'
tempdir = tempfile.mkdtemp()
try:
    ostream = open(fname, 'wb')
    try:
        data = exportXML(connection, oid, ostream)
    finally:
        ostream.close()

    sub._importObjectFromFile(fname, 0, 0)
finally:
    os.rmdir(tempdir)


Thanks for looking into this.
--
Benji York
Senior Software Engineer
Zope Corporation
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to