On 21/03/2006, at 16:45, Michele Cella wrote:

>
> Kevin Dangoor wrote:
>> On 3/21/06, Michele Cella <[EMAIL PROTECTED]> wrote:
>>> I also removed insert and input (and fixed the toolbox) that have  
>>> been
>>> deprecated since a while and in reality never seen a release.  
>>> Should I
>>> add them back?
>>
>> I don't think so... people using the trunk know what they're  
>> getting into.
>>
>
> In r981 I've added support for propagating the generated schema (the
> one used for validation) to all widgets, this allows every widget to
> sync it's self.validator to the one that will be really used, without
> this a widget could have a validator=None but a validator=Int()
> declared on an upper level schema for example leading to  
> inconsistency.
>
> This also simplifies a the is_required management as you can see.
>
> Opinions?

*Very bad idea*. This will lead to unexpected behavior as you're  
changing the validator of a widget that could be reused in other  
forms. Example:

from turbogears.widgets import *
from turbogears.validators import *

class PasswordFields(WidgetsList):
     password = PasswordField()
     password_confirm = PasswordField()

class Passwords(FieldSet):
     name = "passwords"
     fields = PasswordFields()

class Schema1(Schema):
     chained_validators = [FieldsMatch("password", "password_confirm")]
     password = String(min=6)
     password_confirm = String(min=6)

class Schema2(Schema):
     chained_validators = [FieldsMatch("password", "password_confirm")]
     password = String(min=8)
     password_confirm = String(min=8)

form1 = ListForm(fields=[Passwords(validator=Schema1())])
form2 = ListForm(fields=[Passwords(validator=Schema2())])
form3 = ListForm(fields=[Passwords()])

form1.validate(dict(passwords=dict(password="aaaaaa",  
password_confirm="aaaaaa")))
form2.validate(dict(passwords=dict(password="aaaaaaaa",  
password_confirm="aaaaaaaa")))
form3.validate(dict(passwords=dict(password="aaaaaa",  
password_confirm="aaaaaa")))

form3 will have validation and I don't want it. It will make sure  
passwords match and are at least 8 chars long, just because form1 is  
defined before form2, else they will be 6 chars. If this is expected  
behavior you might as well remove copy_schema and give us a big speed  
boost as it's not needed anymore then.

Alberto


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to