Hello
When I create a model which has references, is there a way to make it
without repetition?
# start of code
db.define_table('bugger',
SQLField('name','string'),
SQLField('what','text'),
SQLField('weight','integer'),
)
db.define_table('occurence',
SQLField('bugger_id',db.bugger), # here I define the reference to the
bugger table
SQLField('description','text'),
SQLField('time','datetime',default=datetime.date.today()),
)
db.define_table('nagger',
SQLField('name','string'),
SQLField('characteristics','text'),
)
db.define_table('bugger_nagger',
SQLField('bugger_id',db.bugger), # reference to bugger
SQLField('nagger_id',db.nagger), # reference to nagger
SQLField('since','datetime',default=datetime.date.today()),
SQLField('why','text'),
)
db.occurence.bugger_id.requires=IS_IN_DB(db,'bugger.id','bugger.name')
# here I repeat myself (+bugger.name)
db.bugger_nagger.bugger_id.requires=IS_IN_DB(db,'bugger.id','bugger.name')
# here I repeat myself again
db.bugger_nagger.nagger_id.requires=IS_IN_DB(db,'nagger.id','nagger.name')
# end of code
Is there a way to describe the relationship of two tables with one
keyword?
Or to define a default string representation of a table?
Or to define a default behaviour in the sense of:
SQLField('bugger_id',db.bugger) automatically sets requires to
IS_IN_DB and take a name field as representation? Or the first string
field?
cu and thank you for reading.
Andre
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---