[web2py] Re: Hook to automatically fill in some registration details

2012-06-25 Thread Daniel Gonzalez
That worked, thanks. I took the computed field route. For other newbies 
like me, this is my code, for the time being very simple, but shows what I 
am doing:

def reserve_org_id(row):
return random.randint(0, 1)

db.define_table(
auth.settings.table_user_name,
...
Field('org_id',   'integer',  compute=reserve_org_id),
...
format='%(first_name)s %(last_name)s')

I guess the other option would be very similar (I guess the function is 
also called with a row object - it is not specified in the documentation)

On Tuesday, June 26, 2012 1:23:19 AM UTC+2, Anthony wrote:
>
> You could make org_id a computed 
> field. 
> Or maybe set readable and writable to False and specify a default value 
> (which can be a function).
>
> Anthony
>
>

-- 





[web2py] Re: Hook to automatically fill in some registration details

2012-06-25 Thread Anthony
You could make org_id a computed 
field. 
Or maybe set readable and writable to False and specify a default value 
(which can be a function).

Anthony

On Monday, June 25, 2012 6:29:22 PM UTC-4, Daniel Gonzalez wrote:
>
> Hello,
>
> My application has a special requirement: the user details contain some 
> values which should not be entered by the user, but automatically generated 
> by the system,
> I am planning to add that information to 
> the auth.settings.table_user_name. In this case the field that I am adding 
> is:
>
> Field('org_id',   'integer', unique=True)
>
> What I am planning is, once the user has registered, assign a computed 
> generated value to this field (I get the organization id from a list of 
> available IDs which is stored in another system). Then I need to update the 
> database with this information.
>
> How can I hook into the registration process, without modifying much the 
> registration flow? I would like to leverage as much as possible from the 
> web2py user management process.
>
> Thanks,
> Daniel
>
>

--