Hello.  First off--excellent work.  I've been using SQLAlchemy for a
year or so now, and I must say it's pretty awesome, but that I'm still
learning it.  So, on to my question.

I'm using Twisted's Perspective Broker to sit in between the database
on the server, and wxPython on the client.  For those that don't know,
PB is used to translucently call remote functions and copy objects
back and forth across the network.  I already have a method for making
SA objects "safe" to copy across the network--that's not an issue.  I
don't think you need an understanding of Twisted or PB to help me out
with this, but if you need more information, or think I should send
this to Twisted's lists, please let me know.

When a client connects using PB, the server maintains a connection
with it (along with other data) in what's called an "Avatar".  The
Avatar is used to deal with permissions and such, and in the case of
my app, it's used to manage preferences.  Because I need frequent
access to the underlying Person object (from the person table), I
store it in the Avatar, as it's always available in my PB functions.

Then, when I need to access relations of it, I use object_session(),
so that I can query it.  This works perfectly--most of the time.
Sometimes (as my app grows more complicated), I'll have issues with
object_session() returning None.  I *think* what the problem is is
that I'm loading that Person row elsewhere (by searching for people,
for example), and that's pulling it out of the session that it was
originally in.

I think that I'm using sessions wrong.  I know I should be creating a
new session for every request from PB-- but then how do I store a
persistent copy of the Person object in the Avatar?  Should I create a
new session each time and use session.merge()?  I should probably
*not* use contextual sessions, as, if I understand that correctly, it
wouldn't only help for a singly-threaded program.  I don't need to
access the database asynchronously, so I think that makes things
simpler.

So, any advice?

Thanks,
Jeff
--~--~---------~--~----~------------~-------~--~----~
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