[Zope-dev] Windows Test Failures and XMLExportImport

Benji York benji at zope.com
Mon May 1 07:24:30 EDT 2006


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


More information about the Zope-Dev mailing list