I've seen 
<https://groups.google.com/forum/#!searchin/web2py/propagate$20reference/web2py/igg4X_X8cQQ/5AlWJKE5FYQJ>
 
other posts 
<https://groups.google.com/forum/#!searchin/web2py/propagate$20reference/web2py/RcTFhBcY17Y/-jnoTtM7MpoJ>
 
about doing 
<https://groups.google.com/forum/#!searchin/web2py/propagate$20reference/web2py/igg4X_X8cQQ/5AlWJKE5FYQJ>
 
chain-referencing and how to get the representation/format rather than the 
ID, but I'm not getting the syntax right or something. Is this only 
possible in a requires statement?

Here are the table definitions. Any help is much appreciated.


db.define_table('age_gender_groups',
                Field('age', 'string'), # eg: U10s, U12s, high school, 
junior high, U16s, et c.
                Field('gender', 'string', 
requires=IS_IN_SET(['girls','boys', 'mixed'], zero=None)),
                #format = '%(age)s %(gender)s'
                format = lambda r: '%s %s' % (r.age, r.gender)
               )

db.define_table('program_types',
                Field('name', 'string'),
                Field('stratum', 'integer'),
                #format = '%(name)s'
                format = lambda r: '%s' % (r.name)
               )

db.define_table('programs',
                Field('program_type', 'reference program_types',
                     requires = IS_IN_DB(db, db.program_types, 
db.program_types._format)),
                Field('age_group', 'reference age_gender_groups',
                     requires = IS_IN_DB(db, db.age_gender_groups, 
db.age_gender_groups._format)),
                Field('date_start', 'date'),
                Field('date_end', 'date'),
                Field('coach', 'reference auth_user'),
                Field('assistant', 'reference auth_user'),
                Field('squad', 'integer', default=1)#,        #  to be able 
to sub-divide programs so as to manage size
                #format = '%(program_type)s %(age_group)s'    #  squad# 
%(squad)s'
                #format = lambda r: '%s %s' % (r.program_type, r.age_group)
               )

db.programs._format = lambda r: '%s %s' % (r.program_type, r.age_group)

db.define_table('sessions',
                Field('program_name', 'reference programs',
                      requires = IS_IN_DB(db, db.programs, 
db.programs._format)),
                Field('session_type', 'string', 
requires=IS_IN_SET(['practice', 'evaluation'], zero=None)),
                Field('coach', 'reference auth_user'),
                Field('assistant', 'reference auth_user'),
                Field('session_date_time', 'datetime'),
                #format = '%(program_name)s %(session_type)s 
%(session_date_time)s'
                format = lambda r: '%s at %s on %s' % (r.program_name, 
datetime.time(r.session_date_time), datetime.date(r.session_date_time))
               )



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to