Hi,

I am using the above to set the user language and I am sure this worked for me, but it doesn't any more, in the mean time I upgraded to 0.8.1 (was on 0.7.8) and I wonder where things changed.

In a simple test like this it still works:

session.execute("select rdb$set_context('USER_SESSION', 'LANGUAGE_ID', 3)from rdb$database").fetchone()
session.commit()
result = session.query(db.Drinktype_LV)
for item in result:
    print item.name, item.language.name

I get the correct item and language name values back.

But when I try this in my application the context goes away and I am not sure if this is SA doing this or Firebird.

During the app init (wxPython) I do this:

setcont = "select rdb$set_context('USER_SESSION', 'LANGUAGE_ID', %s) \
            from rdb$database" % self.loggedInUser.language.id
            print wx.GetApp().ds
            x = wx.GetApp().ds.execute(setcont).fetchone()
            y = wx.GetApp().ds.execute(getcont).fetchone()
            assert y[0] == str(self.loggedInUser.language.id)
            wx.GetApp().ds.commit()

Fine so far, now I try to use it e.g. like this:

    app = app_base.BaseApp(redirect=False)

    print app.ds
    getcont = "select rdb$get_context('USER_SESSION', 'LANGUAGE_ID') \
    from rdb$database"
    y = app.ds.execute(getcont).fetchone()
    assert y[0] == str(app.loggedInUser.language.id)

Here the assert fails as the fetch returns None as if the context was not set.

the "print app.ds" both show:
<sqlalchemy.orm.session.SessionMaker object at 0x06D41C90>

app.ds is created with:
maker = sao.sessionmaker(autoflush=True, autocommit=False,
                         expire_on_commit=True)
DBSession = sao.scoped_session(maker)

app.ds = DBSession() # just checked again that I do this only in one place of my code

Anyone has a hint on where I am going wrong with all this?

Werner

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to