Michele Cella wrote:

>IMHO? insane... :D
>
>That's not how an object is supposed to work, why should we use a class
>instead of an instance? it's just not how OOP works and that's why you
>can't do that without resorting to metaclass magic, I hope TG will
>never do something similar because that could really be confusing and
>feel strange to everyone.
>
>But that's only my opinion. ;-)
>
>Ciao
>Michele
>  
>
heh, yeah, I thought it sounded a bit crazy, but I thought of that just 
after waking up this morning.
But, crazy ideas about class/object mutation aside, I think it would be 
preferable to define a form as a class. Besides the aesthetic difference 
(which is a good one IMHO) it could also provide for better functionality.

i.e. you could define custom validation for your fields in the class, 
I'm not sure I like this decorator method that exists now. But to be 
honest, I haven't really used it (partly because of lack of docs).

pseudo example:
class MyForm( WidgetForm ):
    Name = TextField(label=...[, class=..., value=..., size=..., ...])
    Value = TextField(label=...[, class=..., value=..., size=..., ...])
    Submit = SubmitButton(value=...[, name=..., class=...])
   
    def _validateName( self, value ):
        if len( value ) < 4:
            return false
        if not value.isalnum():
            return false
...etc...

then defining a your method could simply be a matter of:

@expose()
@validate(MyForm, postOnly=true)
def save(self, **values):
    # database code here


Anyway, that's my fantasy, I may make it my own reality eventually.

Sean

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

Reply via email to