2008/5/2 Jim Steil <[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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to turbogears@googlegroups.com
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