Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread Simon King
On Mon, Mar 30, 2015 at 1:09 PM, uralbash svintso...@gmail.com wrote: Hello, I want to set up in each session was my custom attribute, for example: from sqlalchemy.orm import scoped_session, sessionmaker Session = my_wapper(scoped_session(sessionmaker())) session1 = Session() session2 =

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
More example in tests https://github.com/ITCase/sacrud/blob/master/sacrud/tests/test_sessionmaker.py def test_create(self): user = self.session.sacrud(User)\ .create({'name': 'Dzhirad', 'fullname': 'Kiri', 'password': 123}) self.assertEqual(user.name, 'Dzhirad')

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
I'm writing a module (sacrud https://github.com/ITCase/sacrud) that is not initially aware of the session. I want to add my session method (sacrud). from sqlalchemy.orm import scoped_session, sessionmaker from sacrud import crud_sessionmaker DBSession =

[sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
Hello, I want to set up in each session was my custom attribute, for example: from sqlalchemy.orm import scoped_session, sessionmaker Session = my_wapper(scoped_session(sessionmaker())) session1 = Session() session2 = Session() hasattr(session1, foo) # True: What I want hasattr(session2, foo)

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread Simon King
Can't you write it like this (untested)? # class CRUDSession(sqlalchemy.orm.Session): def sacrud(self, cls): return CRUD(self, cls) Session = scoped_session(sessionmaker(class_=CRUDSession)) # Simon On Mon, Mar 30, 2015 at 3:15 PM, uralbash svintso...@gmail.com wrote: More

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
Yes, it works. Thank you so much. понедельник, 30 марта 2015 г., 19:58:40 UTC+5 пользователь Simon King написал: Can't you write it like this (untested)? # class CRUDSession(sqlalchemy.orm.Session): def sacrud(self, cls): return CRUD(self, cls) Session =