Found this slice earlier. My objective is to display a filtered lists of villages based on user's previous selection. I get the error <type 'exceptions.KeyError'>('village') after I cloned CascadingSelect class from slice 85[1] for use in the tables[2]. the difference here is that my keys are strings instead of the integer used in the original.
the common field between tables region and province is geocode_r, between province and town is geocode_p, between town and village is geocode_t. Note that table 'town' connect to it's province using the geocode_p but uses geocode_t to connect to the villages. (I could'n't change the geocode structure, and I need the same codes to maintain inter- operability.) Do I need a "straight" link between these tables? I'm thinking that I could work on a copy of the database then create a new field that will make a direct reference from village to town to province to region, and still keep the geocodes for reference but not for generating the cascades fields. What do you think is the error here? [1] http://web2pyslices.com/main/slices/take_slice/85 [2] my tables are defined as follows: gdb.define_table('region', Field('geocode_r', 'string', length=2, default=''), Field('name', 'string', length=12, default=''), format='%(name_short)s', migrate=False) gdb.define_table('province', Field('geocode_r', 'string', length=2, default=''), Field('geocode_p', 'string', length=2, default=''), Field('name', 'string', length=128, default=''), format='%(name)s', migrate=False) gdb.define_table('town', Field('geocode_p', 'string', length=2, default=''), Field('geocode_t', 'string', length=4, default='' ), Field('name', length=128, default=''), format='%(name)s', migrate=False) gdb.define_table('village', Field('geocode_t', 'string', length=4, default=''), Field('geocode', 'string', length=9, default=''), Field('name', 'string', length=128, default=''), format='%(name)s', migrate=False) #instantiate cascade = CascadingSelect(gdb.province, gdb.town, gdb.village)