two problems:
1. the "threadlocal" mode, not a widely used option, currently does
not support begin_nested() (which is somewhat of a surprise to me)
2. the inner() method issues no SQL. add a "sess.flush()" in there,
and do away with "threadlocal" to see it work.
On May 14, 2008, at 3:45 PM, Jacob Gabrielson wrote:
> from sqlalchemy import *
> from sqlalchemy.orm import *
>
> engine = create_engine('mysql://[EMAIL PROTECTED]/test', echo=True,
> strategy='threadlocal')
> meta = MetaData()
> meta.bind = engine
>
> test_table = Table('test_table', meta,
> Column('test_id', Integer, primary_key=True),
> Column('name', String(40)),
> mysql_engine='InnoDB')
>
> meta.create_all()
>
> class MyTest(object):
> def __init__(self, test_name):
> self.name = test_name
>
>
> mapper(MyTest, test_table)
>
> Session = sessionmaker(transactional=False, autoflush=True,
> bind=engine)
>
> def doit():
> sess = Session(transactional=False)
> sess.begin()
>
> t = MyTest("outer")
> sess.save(t)
> sess.flush()
>
> def inner():
> sess.begin_nested()
> t2 = MyTest("inner")
> sess.save(t2)
> sess.rollback()
>
> inner()
>
> sess.commit()
>
> if __name__ == '__main__':
> doit()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---