You cannot set id so you cannot give it a default value.
id is the unique record is assigned by the database.
You should use a different field name and make the field a reference
to t2_person.id.
Massimo
On Dec 9, 5:37 pm, "Wes James" <[EMAIL PROTECTED]> wrote:
> I have:
>
> db.student.id.default=t2.person_id
>
> in my db.py
>
> but I have a problem. When a student comes and registers that creates
> a t2_person record - fine. But then they are logged in and they see
> their initial form. If they save some data, all is fine, but if they
> don't and another student registers, then saves some data then the
> student.id gets out of sync because it is not taking the t2.person_id
> for some reason.
>
> it does this
>
> student 1 registers they get t2.person_id=1 - they save data (before
> anyone else does) and so student.id is also 1
> student 2 registers they get t2.person_id=2 - they don't save data
> sudent 3 registers they get t2.person_id=3 - they save data, but the
> student.id is set as 2.
>
> Shouldn't the default above have prevented this. It seems the
> student.id is just getting set to the next available id when saved.
>
> Would it work better to do:
>
> db.define_table("student",
> SQLField("id",default=t2.person_id),
>
> .....
>
> but "id" is already there isn't it?
>
> thx,
>
> -wj
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---