[Seaside] Session accesible from the model of an application
Markus Gaelli
Markus.Gaelli at suisa.ch
Wed Apr 18 12:34:43 UTC 2007
seaside-bounces at lists.squeakfoundation.org wrote on 18.04.2007 13:09:32:
> Göran Krampe wrote:
> > Hi!
> >
> >
> >> Try implementing a Registry (see "Registry Pattern") and if you are
> >> using magma in single-user mode, implement a singleton on the magma
> >> session. I opted to subclass MagmaSession and provide an #instance
method:
> >>
> >> instance
> >> ^Session ifNil:
> >> [Session _ (MagmaSession openLocal: '/path') connectAs:
'user']
> >>
> >
> > Ehmmm... the problem here (I presume) is that there are multiple
> > MagmaSessions being used in different Processes. So you need to get
hold
> > of the *correct* MagmaSession - not just a singleton.
> >
> > regards, Göran
> >
> > _______________________________________________
> > Seaside mailing list
> > Seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> >
> >
> >
> >
> Hence the "if you are using single user mode" :) The singleton is merely
> for that. Use a Registry to contain the sessions, then pass that around
> your model/application.
Hi,
I recently implemented a facade for this problem along the following
lines:
If there is a seaside session, fetch the DB connection from the seaside
session, otherwise fetch it from some connection holding singleton
independent of Seaside.
This way one can write stand alone tests using the same interface/facade
to the DB as the real application, as the both talk to the switching
facade. As a downside you need to run your tests then while _not_ having a
seaside session running of course.
Hope this helps,
Markus
>
>
> Pinesoft Computers are registered in England, Registered number:
> 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts,
EN8 7EA
>
>
>
> This message has been scanned for viruses by BlackSpider MailControl
> - www.blackspider.com
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
More information about the Seaside
mailing list