Field objects (to define table fields) support default values try something like db.<table name>.<field name>.default = list() or Field("<field name>", ... , default=list())
I haven't used it but I guess that on record creation this should create an empty list field value. On 5 ene, 19:37, Tsvi Mostovicz <ttm...@gmail.com> wrote: > I managed to find the culprit. The function before it had a mismatched > parentheses. So it would continue reading this function and fail on > compilation. Thanks for all your replies. The append works, although > if this is a new user and no list has been defined yet it won't. So I > check if it returns None, set the list to [] and then have the append > statement. > I thought all the vars would be initialized by default so a list type > would return [] if it wasn't set in the form. > > Another thing I learned is the fact that the function must receive one > argument (form). > > Thanks again for the wonderful support. > > Sent from my phone > > On 5 בינו 2012, at 00:17, Alan Etkin <spame...@gmail.com> wrote: > > > And if the auth_user field is of type list:<type>, seems that even it > > is ok to do simply: > > > auth.user.mylistfield.append(object) > > > without explicit db query or update > > > On 4 ene, 18:42, Alan Etkin <spame...@gmail.com> wrote: > >> If you are doing post-registration process, you might want to use > >> auth.settings.register_onaccept: > > >> register_onaccept is a list of functions or a single function or > >> lambda that receive a form argument > > >> form.vars.id contains the id of the new auth_user record. > > >> For appending to a sequence stored in an auth_user record field, maybe > >> it would be better to get the auth_user record field first with a db > >> query, modify it and finally update the db record. > > >> On 4 ene, 11:54, tsvim <ttm...@gmail.com> wrote: > > >>> Hi all, > > >>> I'm trying to use the callbacks for auth.settings.register_onvalidation. > >>> I first put the function in controllers, when I discovered it should be in > >>> models as the settings are there. > >>> Now I have them in models, but I get a invalid syntax error on the last > >>> line: > > >>> def register_new_table_token(): > >>> auth.user.last_opened = session.table_token > >>> auth.add_membership(auth.add_group(session.table_token),auth.user.id) > >>> auth.user.my_budgets.append(session.table_token) > >>> return > > >>> This happens both when I have pass instead of return or I don't enter a > >>> return statement. > > >>> Please help, > > >>> Thanks, > > >>> Tsvi > >