On Jan 25, 2008, at 12:16 PM, Kumar McMillan wrote:

> class ScopedMapperTest(PersistTest):
> @@ -1027,6 +1046,21 @@
>             pass
>         Session.mapper(Baz, table2, extension=ext)
>         assert hasattr(Baz, 'query')
> +
> +    def test_attach_assigned_objects_to_multiple_sess(self):
> +        PrivateSession = scoped_session(create_session,
> scopefunc=lambda: '__private_session__')
> +
> +        so1 = SomeObject()
> +        priv_sess = PrivateSession()
> +        priv_sess.save(so1)
> +        priv_sess.flush()
> +
> +        so2 = SomeObject()
> +        sess = Session()
> +        sess.save(so2)
> +        sess.flush()
> +
> +        PrivateSession.remove()
>
>     def test_validating_constructor(self):
>         s2 = SomeObject(someid=12)
>

the ScopedMapperTest maps the SomeObject class using the `mapper()`  
function on the original Session.  Therefore all SomeObject instances  
are automatically saved to the Session declared in setUp(). so this  
test will pass if you change setUp to read:

         Session.mapper(SomeObject, table, properties={
             'options':relation(SomeOtherObject)
         }, save_on_init=False)
         Session.mapper(SomeOtherObject, table2, save_on_init=False)

The Session.mapper function is not worth it, in my opinion, it exists  
due to the sheer popularity of its previous incarnation,  
"assign_mapper".  I much prefer keeping things explicit.





--~--~---------~--~----~------------~-------~--~----~
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