I used cookie and set db name there. It kind of works :)

I will try out your solution.

One more question though. I want a redirect after user logouts. 

And not to go to default/index page but my specific school/index. I am 
trying with auth.settings.logout_next=URL(r=request,c='school',f='index') 
but it is not working. Where do I write this code? To controler or model? 
If it is right at all

thank you

On Tuesday, August 28, 2012 3:36:18 PM UTC+2, Anthony wrote:
>
> Instead of a default database, how about something like this:
>
> session.database = session.database or request.vars.database
> if not session.database or session.database not in ['list', 'of', 'valid', 
> 'databases']:
>     redirect(URL('default', 'index'))
>
> baza = DAL('postgres://postgres:postgres@localhost/'+ session.database,migrate
> =True)
> auth = Auth(baza)
>
> That expects the database name to be in request.vars.database (via either 
> a get or post request with a "database" variable). Once submitted, the 
> database name will be stored in the session. On each request, before 
> attempting to connect to the database, it will check the session for the 
> database and confirm it is a valid database -- if not, it redirects back to 
> the home page before connecting.
>
> Anthony
>
> On Tuesday, August 28, 2012 3:21:36 AM UTC-4, Yebach wrote:
>>
>> Where do I put  database = session.get('database','default_database') ??
>>
>> In model?
>>
>> So if I understand correctly first there has to be a default database, 
>> but then after user selects the value a connection is set for the selected 
>> database?
>>
>>
>>
>> On Monday, August 27, 2012 8:59:03 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> If this is a new app you may want to replace
>>>
>>>     auth = Auth(baza, hmac_key=Auth.get_or_create_key())
>>>
>>> with
>>>
>>>    auth = Auth(baza)
>>>
>>> as it will be faster and same security because latest Auth has built-in 
>>> salting.
>>>
>>> About your problem. You cannot complete let the user specify it. You 
>>> must have a default and a set of default values:
>>>
>>>     database = session.get('database','default_database')
>>>
>>> The you can have a form that stores the one they want into 
>>> session.database
>>>
>>>
>>>
>>>
>>> On Monday, 27 August 2012 10:09:34 UTC-5, Yebach wrote:
>>>>
>>>> Hello
>>>>
>>>> My problem is that my app has to go to specific database on postgres to 
>>>> check for users. 
>>>> you can visit my app on http://portal.iurnik.si/
>>>>
>>>> You can see that the user select a value from popup and then the app 
>>>> goes to a specific database to read data.
>>>>
>>>> After that I want to create a login form. 
>>>>
>>>> I created it but,.....
>>>>
>>>> I created a separate model users.py  with this code
>>>>
>>>> database = now it is hardcoded so it works all the time
>>>> baza = DAL('postgres://postgres:postgres@localhost/'+ database, 
>>>> migrate=True)
>>>> auth = Auth(baza, hmac_key=Auth.get_or_create_key())
>>>> auth.settings.controller="user"
>>>> auth.define_tables()
>>>>
>>>> But what I would like to do is read the database name from url and the 
>>>> right url comes only after user selects the right value from popup. And 
>>>> that is why the app chashes if I don't hard code the db name. Logically.
>>>>
>>>> What do you suggest? also after logout user would stay on the second 
>>>> page not to go to default page (where do I set that parameter)
>>>>
>>>> Thank you
>>>>
>>>

-- 



Reply via email to