I want to limit IS_IN_DB to a table whose fields match what is being 
entered in an adjoining field in the same table.

Tables: 

*Taxonomy* is the taxonomy type and contains the types of taxonomies, e.g., 
"plants" taxonomy, "computer languages" taxonomy.  

*TaxonomyData* is the detail taxonomy of each taxonomy type, e.g., 

   for "plants", it could have roses, acorn trees, rice, and, 

    for "computer languages", it could have python, java, and perl.

Taxonomy is the parent of TaxonomyData.  

*Suggestion* is a table of suggestions. 

*SuggestionCategorizationIntersection* table categorizes "Suggestion" data 
using Taxonomy and TaxonomyData.

db.define_table('*Suggestion*'...)

db.define_table('*Taxonomy*',
Field('taxonomyShortName','string'), 
Field('taxonomyLongName','string'), 

db.define_table('*TaxonomyData'*,
Field('taxonomyID','reference Taxonomy'), 
Field('taxonomyName','string'), 
Field('taxonomyDataID','string'), 
Field('taxonomyDataName','string'), 

db.define_table('*SuggestionCategorizationIntersection*', 
Field('suggestionID','reference Suggestion'), 
Field('taxonomyID','reference Taxonomy'),
Field('taxonomyDataID','reference TaxonomyData'))

Now if I use the code below, I get ALL of data in TaxonomyData, but I only 
want that data that matches what user typed in the adjoining TaxonomyID 
field in SuggestionCategorizationIntersection.

db.SuggestionCategorizationIntersection.taxonomyDataID.requires = 
IS_IN_DB(db, db.TaxonomyData.id, '%(taxonomyDataName)s',zero=T('choose 
one'))  ##<--- I get too much data

I want to choose from taxonomyDataID data where the taxonomyID for it in 
TaxonomyData only matches the TaxonomyID the user is entering in 
SuggestionCategorizationIntersection.taxonomyDataID. These two fields are 
next to each other in SuggestionCategorizationIntersection.

Ideally, I'd like to be able to do something like this:

db.SuggestionCategorizationIntersection.taxonomyDataID.requires = 
IS_IN_DB(db, db.TaxonomyData.id WHERE TaxonomyData.taxonomyID = 
SuggestionCategorization.TaxonomyID 

The record hasn't been saved yet so how would web2py know what is in 
the SuggestionCategorization.TaxonomyID record user is typing in? See field 
colored red above.

Can someone please write out the syntax for this "requires" clause?  

 I'm testing in the appadmin.

Thanks,

Alex Glaros

-- 

--- 
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/groups/opt_out.


Reply via email to