Re: [web2py] remove references problem

2011-12-15 Thread Nik Go
Yes. Because your first statement only declares a default value for a field
type 'string', the default field type.

The second statement, redefines the field as a reference field which by
default deletes all references if the parent record is deleted.

Check out
ondelete='CASCADE' #this is the default action for any field unless it's
set to 'NO ACTION'

in the book.

On Thursday, December 15, 2011, thodoris wrote:

> Well i guess that doing
>
> db.define_table('cat',
> Field('name'),
> Field('owner',db.person,default=db.**person.id ))
> db.cat.owner.requires = IS_IN_DB(db, db.person.id)
>
> does the job.
>


[web2py] remove references problem

2011-12-15 Thread thodoris
I know that if i declare the following

db.define_table('person',
Field('name'),)

db.define_table('cat',
Field('name'),
Field('owner',db.person))
db.cat.owner.requires = IS_IN_DB(db, db.person.id)

Then if i delete a person, all the cats of this person will be deleted.

But i declare the cat table like this 

db.define_table('cat',
Field('name'),
Field('owner',default=db.person.id))
db.cat.owner.requires = IS_IN_DB(db, db.person.id)

the cats of that person are not deleted and i have a broken reference. Is 
there another way to fix this instead of doing it as described above?