This is a conceptual novice question on automatic transaction handling
and flush (sqlalchemy).

As a controller method automatically runs in a transaction, I was
thinking that any flushed data should be rolled back if an exception
occurs in between. The code below and inline comments elaborate my
point.

@expose()
def create_company(company_name, ceo_name)
    company = Company(name=company_name)
    session.flush()   # so that company.id is generated
    employee = Employee(name=ceo_name)
    company.employees.append(employee)
    ### if I raise an exception here, the company data is not rolled
back #
    ### But should not it get rolled back, if the automatic transaction
is around?
    session.flush() # so that employee.id is generated
    company.ceo_id = employee.id

As I intrepreted SQLAlchemy docs, multiple flush() can be done in
between a transaction. Am I missing some concepts?

thanks
sanjay


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to