Hi,
Thank you, works fine now. Do you have a link to some doc explaining why
this step is required?

Thank you,
Fabian 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alberto Valverde
Sent: 28 February 2007 05:20
To: [email protected]
Subject: [TurboGears] Re: Select Field entries not updating? Are they being
cached?



On Feb 28, 2007, at 4:18 AM, schnuer.com wrote:

>
>  Yes, i have a helper function that can build the appropriate  
> options list.
>
> Here is a sample select list and the util fnc making the values  
> that go in:
>
>
> objectSubTypeID = widgets.SingleSelectField(label="Object Type",
> legend=_("Type"),validator=validators.Int,
> options=myprojectweb.utils.makeOptions 
> (myprojectweb.model.objectSubType.sele
> ct(),'subTypeName'))
>
> def makeOptions(results, labelColumn, seperatorColumn=None,
> AddNull=False,MultiLang=False):
>     values = []
>     for result in results:
>         try:
>             label = getattr(result,labelColumn)
>         except:
>             if MultiLang == True:
>                 label = 'LabelNotFound'
>             else:
>                 for lang in list(myprojectweb.model.languages.select 
> ()):
>                     label[lang.languageCode] = 'Error'
>         if MultiLang == False:
>             values.append((result.id,
> label[myprojectweb.utils.getActiveLanguage()]))
>         else:
>             values.append((result.id, label))
>     if AddNull == True:
>         values.insert(0,('-1',' '))
>     return values

If there's no typo here you're not passing a callable but the result  
of the call to makeOptions. You'll need a closure for that to work:

def makeOptions(results, labelColumn, seperatorColumn=None,
AddNull=False,MultiLang=False):
     def get_options():
         values = []
         for result in results:
             try:
                 label = getattr(result,labelColumn)
             except:
                 if MultiLang == True:
                     label = 'LabelNotFound'
                 else:
                     for lang in list 
(myprojectweb.model.languages.select()):
                         label[lang.languageCode] = 'Error'
             if MultiLang == False:
                 values.append((result.id,label 
[myprojectweb.utils.getActiveLanguage()]))
             else:
                 values.append((result.id, label))
         if AddNull == True:
             values.insert(0,('-1',' '))
         return values
     return get_options

HTH,
Alberto




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to