I could send you a private email later but the general flow is:
index.html
----------
{{extend 'layout.html'}}
<TABLE>
<THEAD>
<TR>
<TH>TS database</TH>
<TH>B1 database</TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD>{{=LOAD(url=URL('TSlogin.load'), ajax=True,
target='TSlogin')}}</TD>
<TD>{{=LOAD(url=URL('B1login.load'), ajax=True,
target='B1login')}}</TD>
</TR>
<TR>
<TD>{{=LOAD(url=URL('TStables.load'), ajax=True,
target='TStables')}}</TD>
<TD>{{=LOAD(url=URL('B1tables.load'), ajax=True,
target='B1tables')}}</TD>
</TR>
<TBODY>
</TABLE>
TSlogin & B1login show a login form asking for user/pass,
on accepts they try to open the connection,
if successful they redirect to TSlogout or B1logout
which show a read only version of the login form with
a 'logoff' submit which repeats this cycle.
The connection status is kept in the session.
Logins/logouts also reload the 'tables' components
depending on the connection status,
using the refresh function detailed in:
http://groups.google.com/group/web2py-developers/browse_thread/thread/56697ffca2027134#
The login/logout functions are pretty standard:
...
form = SQLFORM.factory(...)
if form.accepts(request, session, formname=func_name):
...
Sometimes one login works while the other does not,
at least not on the first try.