On Jan 11, 2010, at 7:07 PM, Manlio Perillo wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi.
> 
> I'm updating some of my code to SQLALchemy 0.6, and I have noted a
> problem with the sessionmaker function.
> 
> The problem is a compatibility one: old versions use the transactional
> parameter, new ones the autocommit parameter.
> 
> Usually, to handle these problems I use the try/except method:
> 
> try:
>    return orm.sessionmaker(bind=bind, autocommit=autocommit)
> except TypeError:
>    # COMPAT: SQLAlchemy 0.4.x, deprecated in 0.5.x
>    transactional = not autocommit
>    return orm.sessionmaker(bind=bind, transactional=transactional)
> 
> 
> However this does not work, since error is raise only ewhen the actual
> Session instance is created.
> 
> 
> As far as can understand, the sessionmaker function supports keyword
> arguments since user can specify a custom session class to use.
> 
> Can error handling be improved?

i think instead of putting try/excepts all over the place in an attempt to 
achieve compat with 0.4 thorugh 0.6, just look at sqlalchemy.__version__ to 
determine the correct API.

0.4 also has severe performance issues so I'd urge everyone to drop it if they 
haven't already.


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


Reply via email to