I have the following very simple program with SA0.2, which just
changes a field of a selected object and flushes it back to the
database:

import sqlalchemy.mods.threadlocal
from sqlalchemy import *

meta = BoundMetaData('postgres://postgres:[EMAIL PROTECTED]/test', echo=True)

class Brand(object):  pass
t_brands = Table('brands', meta, autoload=True)
Brand.mapper = mapper(Brand, t_brands)

brands = Brand.mapper.select()
brands[1].brand_name = 'BrandNew'
objectstore.flush()

Running the program gives the following output:

...
[2006-05-18 07:43:37,858] [engine]: {}
[2006-05-18 07:43:37,890] [engine]: BEGIN
[2006-05-18 07:43:37,905] [engine]: UPDATE brands SET
brand_name=%(brand_name)s WHERE brands.brand_id = %(brands_brand_id)s
[2006-05-18 07:43:37,921] [engine]: {'brand_name': 'BrandNew',
'brands_brand_id': 2}
[2006-05-18 07:43:37,953] [engine]: COMMIT
Traceback (most recent call last):
 File "simple_test.py", line 15, in ?
   objectstore.flush()
 File 
"d:\Python24\lib\site-packages\sqlalchemy-0.1.6-py2.4.egg\sqlalchemy\orm\session.py",
line 233, in flush
   self.uow.flush(self, objects, echo=self.echo_uow)
 File 
"d:\Python24\lib\site-packages\sqlalchemy-0.1.6-py2.4.egg\sqlalchemy\orm\unitofwork.py",
line 243, in flush
   trans.rollback()
 File 
"d:\Python24\lib\site-packages\sqlalchemy-0.1.6-py2.4.egg\sqlalchemy\orm\session.py",
line 55, in rollback
   t[1].rollback()
 File 
"d:\Python24\lib\site-packages\sqlalchemy-0.1.6-py2.4.egg\sqlalchemy\engine\threadlocal.py",
line 12, in rollback
   base.Transaction.rollback(self)
 File 
"d:\Python24\lib\site-packages\sqlalchemy-0.1.6-py2.4.egg\sqlalchemy\engine\base.py",
line 340, in rollback
   raise exceptions.InvalidRequestError("This transaction is inactive")
sqlalchemy.exceptions.InvalidRequestError: This transaction is inactive

What could be wrong? By the way, is the main functions described in
SA0.2 documentation fully implemented? For example, the function
current_session doesn't seem to exist.

I am trying to switch to SA as my ORM for a production system. Shall I
start with SA0.17 or directly with SA0.2?

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
R颧�:&q�[嘿�y�hv�ō�^y�h碴i⒒py����z�r赈�!�端n}�h�戤��%������{^�董y�^r���2����歙焊�m娆�昝�
   濉�H��m*az����bq�b�t��鳙�]5m�v�昆�!xg��xΒm���zV�呵��F���遍\�

Reply via email to