Ouch, I'm going to have to defer to to someone who understands smartgrid
better than I do.  You've got me stumped on this one.


On Fri, Feb 22, 2013 at 2:48 PM, Alex Glaros <alexgla...@gmail.com> wrote:

> thanks for offering to take a look.
>
> Screen shots here:
> https://docs.google.com/document/d/1e517YRN8FK08vqsVWmp1UuZ0LLevCNlkrhWyCkBQ7uQ/edit?usp=sharing
>
> Alex
>
>
> On Friday, February 22, 2013 12:16:39 PM UTC-8, Jim S wrote:
>
>> Sorry, I'm kinda lost in what you're trying to do.  Can you show it in
>> code or screen shots?
>>
>> -Jim
>>
>>
>> On Fri, Feb 22, 2013 at 12:08 PM, Alex Glaros <alexg...@gmail.com> wrote:
>>
>>> There is a grandparent (HumanLanguage), parent (DictionaryType), child
>>> (Word), relationship.  If I go straight from the grandparent to the child,
>>> "represent" works.
>>> (First I click on HumanLangages, then I click on Word)
>>>
>>> If I go from the parent to the child, I get this message: <type
>>> 'exceptions.TypeError'> <lambda>() takes exactly 2 arguments (1 given)
>>> (First I click on HumanLangages, then I click on DictionaryType, then, I
>>> click on Word)
>>>
>>> If I reduce the number of parms to db.Word.dictionaryTypeID.**represent
>>> = lambda id: db.DictionaryType(id).**dictionaryName, then it works if I
>>> go from the parent to the child, but if I go from the grandparent to the
>>> child, I get <type 'exceptions.TypeError'> <lambda>() takes exactly 1
>>> argument (2 given).
>>>
>>> If a join was allowed, it would solve the problem but I think they are
>>> not supported in smartgrid.
>>>
>>> Any ideas would be much appreciated,
>>>
>>> Thanks,
>>>
>>> Alex
>>>
>>>
>>> On Friday, February 22, 2013 5:24:48 AM UTC-8, Jim S wrote:
>>>
>>>> Depends on whether or not you want that behavior globally or not.
>>>>  Remember, your model gets executed on every request.  So, if you want that
>>>> behavior globally I'd put it there.  If you just need it for one instance,
>>>> put it in the controller.
>>>>
>>>> -Jim
>>>>
>>>>
>>>> On Fri, Feb 22, 2013 at 12:20 AM, Alex Glaros <alexg...@gmail.com>wrote:
>>>>
>>>>> It worked Jim
>>>>>
>>>>> thanks so much for going through the process of writing and testing
>>>>> the code.
>>>>>
>>>>> I'm new to web2py, is there any preference as to where that statement
>>>>> goes: controller or model?
>>>>>
>>>>> much appreciated,
>>>>>
>>>>> Alex
>>>>>
>>>>>
>>>>> On Thu, Feb 21, 2013 at 8:31 PM, Jim S <j...@qlf.com> wrote:
>>>>>
>>>>>> Add this line before creating your smartgrid:
>>>>>>
>>>>>> db.Word.dictionaryTypeID.**repre**sent = lambda s,r: s.dictionaryName
>>>>>>
>>>>>> Does that help?  It worked for the trimmed down model I made...
>>>>>>
>>>>>> -Jim
>>>>>>
>>>>>>
>>>>>> On Thursday, February 21, 2013 9:16:39 PM UTC-6, Alex Glaros wrote:
>>>>>>>
>>>>>>> db.define_table('**HumanLanguage**',Field('**languageName','**
>>>>>>> string'),Field(**'**forumLocations','string'),**Fiel**d('comments','string'),
>>>>>>> auth.signature)
>>>>>>> db.HumanLanguage.languageName.****requires = IS_NOT_EMPTY()
>>>>>>>
>>>>>>> db.define_table('Word',Field('****wordName','string'), Field
>>>>>>> ('definition', 'string'), Field('languageID','reference
>>>>>>> HumanLanguage'),Field('**diction**aryTypeID','reference
>>>>>>> DictionaryType'),Field('**wordRe**ferenceModelID','**reference
>>>>>>> WordReferenceModel'), Field('comments','string'), auth.signature)
>>>>>>> db.Word.languageID.requires = IS_IN_DB(db, 'HumanLanguage.id',
>>>>>>> '%(languageName)s',zero=T('**cho**ose one'))
>>>>>>> db.Word.dictionaryTypeID.**requi**res = IS_IN_DB(db,
>>>>>>> 'DictionaryType.id', '%(dictionaryName)s',zero=T('**c**hoose one'))
>>>>>>> db.Word.wordName.requires = IS_NOT_EMPTY()
>>>>>>> db.Word.wordReferenceModelID.**r**equires = IS_NULL_OR(IS_IN_DB(db,
>>>>>>> 'WordReferenceModel.id', '%(wordID)s',zero=T('choose one')))
>>>>>>>
>>>>>>> ## Uses English language as standard connector between all
>>>>>>> languages. WordID below points to the English version of the word that 
>>>>>>> is
>>>>>>> the standard. The reason "Is_Null" clause is there is because the first
>>>>>>> time the word is encountered, it won't be in the English dictionary
>>>>>>> db.define_table('**WordReference**Model',Field('**wordID','**reference
>>>>>>> Word'),Field('**dictionaryTypeID**','reference DictionaryType'),
>>>>>>> Field('picture', 'upload', default=''),Field('comments','****string'),
>>>>>>> auth.signature)
>>>>>>> db.WordReferenceModel.wordID.**r**equires = IS_NOT_EMPTY()
>>>>>>> db.WordReferenceModel.wordID.**r**equires = IS_IN_DB(db, 'Word.id',
>>>>>>> '%(wordName)s',zero=T('choose one'))
>>>>>>> db.WordReferenceModel.**dictiona**ryTypeID.requires = IS_IN_DB(db,
>>>>>>> 'DictionaryType.id', '%(dictionaryName)s',zero=T('**c**hoose one'))
>>>>>>> ## dictionary_type_query = (db.DictionaryType.**dictionaryN**
>>>>>>> ame=='English')
>>>>>>> ## /* need this too for wordReferenceModel */
>>>>>>>
>>>>>>> ## Dictionary type means what category of dictionary is it? Medical,
>>>>>>> computer,etc.  There is one for each language.
>>>>>>> db.define_table('**DictionaryTyp**e',Field('**dictionaryName','**
>>>>>>> string'),**Field('comments','**string'),
>>>>>>> Field('languageID','reference HumanLanguage'),
>>>>>>>     Field('**DictionaryReferenceMode**lID', 'reference
>>>>>>> DictionaryReferenceModel'), auth.signature)
>>>>>>> db.DictionaryType.**dictionaryNa**me.requires = IS_NOT_EMPTY()
>>>>>>> db.DictionaryType.languageID.**r**equires = IS_IN_DB(db,
>>>>>>> 'HumanLanguage.id', '%(languageName)s',zero=T('**cho**ose one'))
>>>>>>>  db.DictionaryType.**DictionaryRe**ferenceModelID.**requires =
>>>>>>> IS_IN_DB(db, 'DictionaryReferenceModel.id', 
>>>>>>> '%(DictionaryTypeID)s',zero=T(
>>>>>>> ****'choose one'))
>>>>>>>
>>>>>>> ## Uses English dictionary type as standard connector between all
>>>>>>> dictionary types. DictionaryType.id points to the English 
>>>>>>> DictionaryType.id
>>>>>>> db.define_table('**DictionaryRef**erenceModel',
>>>>>>> Field('DictionaryTypeID','**refe**rence DictionaryType'),Field('**
>>>>>>> commen**ts','string'),
>>>>>>>     auth.signature)
>>>>>>> db.DictionaryReferenceModel.**Di**ctionaryTypeID.requires =
>>>>>>> IS_NOT_EMPTY()
>>>>>>>
>>>>>>> db.define_table('Synonyms',**Fie**ld('synonymName','string'),**Fie**ld('wordID','reference
>>>>>>> Word'),Field('comments','**strin**g'),
>>>>>>>     auth.signature)
>>>>>>> db.Synonyms.synonymName.**requir**es = IS_NOT_EMPTY()
>>>>>>> db.Synonyms.wordID.requires = IS_NOT_EMPTY()
>>>>>>> db.Synonyms.wordID.requires = IS_IN_DB(db, 'Word.id',
>>>>>>> '%(Word)s',zero=T('choose one'))
>>>>>>>
>>>>>>> db.define_table('**PublicComment**s',Field('wordID'**,'reference
>>>>>>> Word'),Field('comments','**strin**g'),
>>>>>>>     auth.signature)
>>>>>>> db.PublicComments.comments.**req**uires = IS_NOT_EMPTY()
>>>>>>> db.PublicComments.wordID.**requi**res = IS_NOT_EMPTY()
>>>>>>> db.PublicComments.wordID.**requi**res = IS_IN_DB(db, 'Word.id',
>>>>>>> '%(wordName)s',zero=T('choose one'))
>>>>>>>
>>>>>>>
>>>>>>> On Thursday, February 21, 2013 6:10:56 PM UTC-8, Jim S wrote:
>>>>>>>>
>>>>>>>> Can you show the model code?
>>>>>>>>
>>>>>>>> -Jim
>>>>>>>>
>>>>>>>> On Thursday, February 21, 2013 7:35:52 PM UTC-6, Alex Glaros wrote:
>>>>>>>>>
>>>>>>>>> Instead of *db.Word.dictionaryTypeID* displaying (which is a
>>>>>>>>> foreign key in db.Word), I’d like a value from the foreign table to 
>>>>>>>>> appear,
>>>>>>>>> i.e., DictionaryType. dictionaryName.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> In the example below, when user cascades down to the Word table,
>>>>>>>>> it only shows db.Word.dictionaryTypeID but I’d like to add the
>>>>>>>>> corresponding DictionaryType. dictionaryName value to it.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> def search_lang():
>>>>>>>>>
>>>>>>>>>    grid = SQLFORM.smartgrid(db.**HumanLang**uage,
>>>>>>>>> linked_tables=['Word','**Diction**aryType'], fields = [
>>>>>>>>> db.HumanLanguage.id, db.HumanLanguage.languageName, db.Word.id,
>>>>>>>>> db.Word.wordName, db.Word.definition, db.DictionaryType.**
>>>>>>>>> dictionaryNa**me,
>>>>>>>>>
>>>>>>>>>        *db.Word.dictionaryTypeID*],
>>>>>>>>>
>>>>>>>>>        user_signature=False)
>>>>>>>>>
>>>>>>>>>    return dict(grid=grid)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> id<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.id>
>>>>>>>>>   
>>>>>>>>> Wordname<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.wordName>
>>>>>>>>>   
>>>>>>>>> Definition<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.definition>
>>>>>>>>>   
>>>>>>>>> Dictionarytypeid<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.dictionaryTypeID>
>>>>>>>>> 1 beaker    glass jar     1
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Want to replace the "1" under Dictionarytypeid with value from
>>>>>>>>> foreign table.
>>>>>>>>>
>>>>>>>>> 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 web2py+un...@**googlegroups.com.
>>>>>>
>>>>>> For more options, visit 
>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> 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 web2py+un...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>> ---
>>> 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 web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to