[Cubicweb] cw shell and user sessions

Stéphane Bugat stephane.bugat at free.fr
Tue Jul 31 16:11:27 CEST 2012


Aurélien, as unbelievable as it is, it works! Just needed to use ``s = session.hijack(user)`` instead of the ``with`` statement, because session does not have an __exit__() method.
A priori a simple s.close() is sufficient to go back to the admin session.

I really like this 'untested' workaround - although it sounds a bit violent ;-)

----- Mail original -----
> De: "Aurélien Campéas" <aurelien.campeas at logilab.fr>
> À: "Stéphane Bugat" <stephane.bugat at free.fr>
> Cc: cubicweb at lists.cubicweb.org
> Envoyé: Mardi 31 Juillet 2012 15:50:11
> Objet: Re: [Cubicweb] cw shell and user sessions
> 
> Le 31/07/2012 15:36, Stéphane Bugat a écrit :
> > Sorry for this hailstorm of questions, but you probably know that
> > the summer is really a suitable time for development.
> >
> > So just a simple question: when using a cw shell session, is it
> > possible to reconnect using another user login? I know it is
> > possible in unitests, using the self.login() method of CubicWebTC,
> > but it doesn't seem to be available in a shell session.
> >
> > Thanks in advance
> >
> > Stephane
> >
> >
> 
> 
> You may want to try;
> 
> with session.hijack_user(someuser) as s:
>     s.execute(...)
> 
> (untested)
> 



More information about the Cubicweb mailing list