Cecil Westerhof wrote:
> 2008/5/2 Jim Steil <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:
>
>>     The complete class:
>>     #####
>>     class DogFields(WidgetsList):
>>         name          = TextField(label     = 'Naam *',
>>                                   validator = validators.NotEmpty)
>>         description   = TextField(label     = 'Omschrijving')
>>         sex           = EnumCol(  label     = 'Geslacht')
>>         morningFood   = TextField(label     = 'Ochtendvoer')
>>         afternoonFood = TextField(label     = 'Middagvoer')
>>         eveningFood   = TextField(label     = 'Avondvoer')
>>         notes         = TextField(label     = 'Opmerkingen')
>>         owner         = SingleSelectField(label   = 'Eigenaar',
>>                                           name    = 'owner',
>>                                           options = ownerOptions,
>>                                           default = 3)
>>     #####
>
> [cut]
>
>>
>>     I would like to have record.owner as the default instead of the
>>     hardcoded 3. How do I do that?
>     In my opinion, you should be setting your default using your
>     controller, and not in the widget definition.  Separate the logic
>     from the display definition.
>
>
> I would like to, but I know not enough from python yet. I would like 
> to give the value to the class, but I do not know how to use it at the 
> right place. (Where default is assigned.)
> For example:
>     class Dummy():
>         def __init__(self, value):
>             print value                                        <= works
>             self.value = value                            <= works
>
>         def testing(self):
>             print 'In test: %d' % self.value        <= works
>
>         def returnValue(self):
>             return self.value                            <= works
>
>         print 'after init: %s' % self.value          <= DOES NOT WORK
>
>     dummy = Dummy(12)
>     print dummy.value                               <= works
>     dummy.testing()                                   <= works
>     print dummy.returnValue()                 <= works
>
> -- 
> Cecil Westerhof
> >
Cecil:

If possible, I'd try to get a copy of Mark Ramm's Turbogears book.  He 
has a number of great examples there that I used to get started with 
TG.  Here is a link to it on Amazon:

http://www.amazon.com/Rapid-Web-Applications-TurboGears-Ajax-Powered/dp/0132433885/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1209757947&sr=8-1

...or, go to www.turbogearsbook.com and use the link there to order it.

    -Jim

--~--~---------~--~----~------------~-------~--~----~
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