def doFile(file): if file in context.objectIds(): context.manage_delObjects(file) doc = context.invokeFactory(type_name='Document', id=file) ok = doc in context.objectIds() docObj = context[doc] newText=str(srcFolder[file]) newText = newText.replace('

','') docObj.setText(newText) print "created document %s" % doc return printed srcFolder=context['src'] srcFiles=srcFolder.objectIds() for f in srcFiles: print doFile(f) return printed