--On 16. Mai 2007 13:45:21 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote:
new to the FAQ: http://www.sqlalchemy.org/trac/wiki/ FAQ#FlushError:instancesomeinstanceisanunsavedpendinginstanceandisanorph an
The FAQ does not explain the problem. Look at the real code: def importImagesFromFilesystem(self, lidx, imgdir): """ Import all images from a local filesystem into the staging area of the Medium. """ # get hold of the Medium object and the persistent object medium = self.mediendb.getMedium(lidx) ^^^^^^^^ returns an existing Medium rowVersion, VersionFile = self.mediendb.connection.getMappers('versions', 'files')
^^^^^^^^^^^^^ returns the mappers for Versions and Files files = [] filelist = [list of some filenames] for name in filelist: vf = VersionFile(format_id=format_id, width=width, height=height, size=size, sha1hash=hash) files.append(vf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ collect all VersionFile instances medium.versions.append(Version(version=0)) ^^^^^^^^^^^^^^^^^^^^^^^^^ Attach a new Version() to the medium medium.versions[0].files = files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attach the collected VersionFile instances to the Version This code causes the trouble. There is no save() operation involved - just a flush() operation driven by the Zope transaction integration of SA. -aj
pgpGTJidZwC4n.pgp
Description: PGP signature