On May 17, 2007, at 4:16 AM, Andreas Jung wrote:

> 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 row
>
>        Version, 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.


theres definitely a save() operation, its occuring via cascade rules  
set up on mappers for Version, VersionFile somehow.   I added another  
unit test in 2624 which tests specifically assigning a list of items  
at once like the above is doing, where the elements would otherwise  
be orphans; and it works.  youll have to distill your TG code into an  
independently runnable test script if you still can't figure it out.






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to