Hi,

I'm migrating my Pylons application to the latest version of Pylons 
(0.9.6rc2) and SA (0.4.0dev-r3205) using the new scoped_session instead 
of the deprecated SessionContext. From the SA docs (0.4), there's a note 
about how .flush() works:

http://www.sqlalchemy.org/docs/04/unitofwork.html#unitofwork_api_flush_whatis

And here I saw that the refresh() method, I never payed attention to it.

Here is my scenario (abreviated):

-------------------------
Session = scoped_session(sessionmaker(autoflush=False, transactional=False))
mapper = Session.mapper

address_table = Table(......)
class Address(object): pass
mapper(Address, address_table, props={...}, order_by=name)

user_table = Table(......)
class User(object): pass
mapper(User, user_table, props={...}, order_by=email)


user = User.query.get(id)
address = Address()

# This will auto-query the DB to get the address listing.
user.addresses.append(address)

Session.flush() # Uninstantiated 'Session' object

# This returns the user's addresses, but the newly appended address will
# be at the end of the list, not ordered correctly.
#return user.addresses

# So I re-build my query and re-fetch from the database that will return
# the user's addresses correctly ordered
return model.Address.query.filter_by(user=user).all()
-------------------------

I guess the last line is OK, but I thought using the refresh() method as 
it's proposed. But refresh() doesn't seem to be available from my 
uninstantiated scoped_session. Instantiating the Session gives me a 
refresh() method (and a bunch of others) but the code breaks earlier at 
the mapper() stage complaining:

TypeError: mapper() got an unexpected keyword argument 'order_by'

I might not be doing a correct usage of scoped_session though. Please 
let me know if I'm doing something wrong.

Regards,
-- 
Alexandre CONRAD


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