[web2py] Re: field related to auth.user.id problem when user not logged in

2011-11-21 Thread Anthony
On Monday, November 21, 2011 10:38:27 AM UTC-5, thodoris wrote:
>
> Thanx for the help guys, what i did finally is
>
> db.videos.table.requires = IS_EMPTY_OR
> (IS_IN_DB(db(db.table.author_id==auth.user_id), db.table.id, '%
> (title)s'))
>
>  What about displaying a BIG dropdown list of "tables" entries? Any
> help here ???
>
What do you mean? Do you want a dropdown when there is no auth user, or 
only when there is? Does the IS_EMPTY_OR cause the dropdown to go away 
(normally IS_IN_DB automatically produces a dropdown)?



[web2py] Re: field related to auth.user.id problem when user not logged in

2011-11-21 Thread thodoris
Thanx for the help guys, what i did finally is

db.videos.table.requires = IS_EMPTY_OR
(IS_IN_DB(db(db.table.author_id==auth.user_id), db.table.id, '%
(title)s'))

 What about displaying a BIG dropdown list of "tables" entries? Any
help here ???

On Nov 21, 4:09 pm, Anthony  wrote:
> > But, according to your define_table()'s, these tables can only be
> > managed (insert or update) with a logged user, or default contents
> > will raise an excpetion because there's no logged user.
>
> The defaults won't raise an exception (as long as auth is defined prior to
> the table definitions), because auth.user_id simply returns None when the
> user is not logged in (i.e., it is not undefined). The same is true for
> auth.user -- it returns None when there is no logged in user (though
> auth.user.id will raise an exception because if auth.user is None,
> obviously it has no 'id' attribute).
>
> See very end of this
> section:http://web2py.com/book/default/chapter/08#Authentication
>
> Anthony


[web2py] Re: field related to auth.user.id problem when user not logged in

2011-11-21 Thread Anthony

>
> db.videos.table.requires = IS_IN_DB(db(db.table.author_id==auth.user.id), 
> db.table.id, '%(title)s')
>
Maybe db(db.table.author_id == (auth.user and auth.user.id))

That will return no records when there is no auth.user.

Anthony