Here is a sample code:
print session.is_active()
class MySessionExtension(SessionExtension):
print "Entering MySessionExtension"
def before_flush(self, session, flush_context, instances):
print "Entering method before_flush"
session.configure(extension=MySessionExtension())
# some data manipulation goes here with session.add(), session.delete
()
session.flush()
session.commit()
My session is active, I can see the trace "Entering
MySessionExtension" but I never see any "Entering method before_flush"
even if my objects are well stored or deleted in the database.
I use declarative and SA 0.5.5
Any clue ?
Regards,
Laurent
On 10 sep, 10:29, asrenzo <[email protected]> wrote:
> I also tried session.configure(extension=MySessionExtension()) with no
> success
>
> On 10 sep, 10:13, Laurent Rahuel <[email protected]> wrote:
>
> > Hi,
>
> > I'm currently using a webframework which uses sqlalchemy. Each time a
> > request hits the server, the framework creates a session object I can
> > use during the page creation.
>
> > I wish you could update this session with one of my SessionExtension but
> > I'm facing a small problem:
>
> > I tested my code with a standalone session I had created with this
> > syntax : session = create_session(extension=MySessionExtension()) and
> > everything works. When I try the same code in my web context and I do:
>
> > """""""""""""""""
> > from framework.db import session
>
> > session.extension = MySessionExtension()
>
> > .
> > .
> > .
>
> > """""""""""""""
>
> > None of my extension session methods are called.
>
> > Any idea ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---