Michael

On Jul 3, 3:58 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jul 3, 2008, at 5:05 AM, Iwan wrote:
> > I was wondering if it is not possible to do something that is local to
> > the current call-stack, instead of the current thread.
> [SNIP]
>
> the "currentframe" usage is something I'd leave to the deeper Python  
> folks to argue over its appropriateness.  

Yes, once I have established a use-case for it here, I'll discuss the
mechanism on the python lists.

> As far as SA's contextual  
> session, it was always meant to allow any kind of context, not just  
> threadlocal.  Here, it would look like:
>
> Session = scoped_session(sessionmaker(), scopefunc=get_context)
>
> where "get_context" needs to return anything that is hashable, to key  
> off to the Session inside of a dict.

OK, I've had a look at that code. Just to make sure I get it, would
the following theoretically work?

Assume I have a class, CC, which is smart enough to maintain a
_singleton_ instance of a normal dict somewhere on the callstack. If
you do CC.get_context(), it will always return that single dict.
Assume also that CC.get_context_hash() returns id(CC.get_context())

Then, what you're saying is that I can do:

Session = scoped_session(sessionmaker(),
scopefunc=CC.get_context_hash)

And that's it? Does this make sense?

-i

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