Hello Mike,
On 8/3/07, Mike Orr <[EMAIL PROTECTED]> wrote:
>
>
> > Is it optimal setup? What if make a DatabaseFacade created just once,
> > instead of per-request? Would it remain thread-safe?
>
> No. sac.session is the session appropriate to the current thread (and
> application for multi-app sites). You'd be saving a session in one
> thread and using it in another thread. Worse, the session you clear
> in the base controller would be different than the session used by a
> DatabaseFacade method.
Thanks for the explanation, I see your point.
Are you sure you need a DatabaseFacade class? If there's only one
> instance, it's the same as a module. So you can recast your
> high-level access methods as functions:
Yep, that's one approach. I wanted a DatabaseFacade class so I can stub its
interface for testing.
I suppose if I just make it stateless (see below) it will work nicely:
class DatabaseFacade(object):
def __init__(self):
self.meta = sac.get_metadata("blog") # also a shortcut
session = property(fget=lambda self: sac.session)
Max.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---