I actually did this and it worked,

I put this at the top of my module file:
def func():
    if auth.user == None:
        return "Anon"
    else:
        return auth.user.first_name

and in my table definition I did this:
Field("auctioner", "string", default = func(), required=True,
readable=False, writable=False)

I just dont know if my approach has performance issues?



On Oct 29, 11:46 pm, Anthony <abasta...@gmail.com> wrote:
> default=auth.user.first_name if auth.user else 'some_other_default'
>
> or
>
> default=auth.user and auth.user.first_name or 'some_other_default'
>
> Anthony
>
>
>
>
>
>
>
> On Saturday, October 29, 2011 6:10:34 PM UTC-4, Pystar wrote:
>
> > In an app I am developing, in my database definition I have a filed
> > whose default value is auth.user.first_name, but I noticed that when I
> > try to run the app it gives me an error since there is no user logged
> > in and auth.user  == None and the None value doesnt have a first_name
> > attribute. How then do I solve this?
> > P.S: I hope my explanation is clear enough?

Reply via email to