On Jan 8, 2007, at 5:24 PM, Jorge Godoy wrote:


Alberto Valverde <[EMAIL PROTECTED]> writes:

I was thinking of something more like a a Schema subclass (which you'd have
to subclass if you want this functionallity that did  something like:

class TGSmartSchema(Schema):
        def _to_python(self, value, state=None):
                disabled_fields = pickle.loads(
                        self.decrypt(value.pop('form_state'))
                        )['disabled_fields']
                self.disable_fields_for_request(disabled_fields, state)
                return super(self, TGSmartSchema)._to_python(value, state)

That should make possible to use the same schema and let the form decide when being displayed which fields should be disabled or whatever. Mind, that state could not be changed client-side unless the code that generates the hash can be called asyncronously to provide new hashes based on parameters (which could, by the way, make the implementation less secure as more and more bits of the key could be computed by watching how the hash varies as parameters change (if same key is reused)). Phew... not something I'd like to implement
myself... ;)

This has this advantage that you noticed. One of the most interesting things
is being able to change the form according to the selected options...
One thing that I was thinking...  How feasible would it be calling the
validator for the returned fields only? I mean, when something is disabled it doesn't get submitted on the POST or GET action. We already know what has
been sent because these fields aren't there.

This applies inly if submission is done by a well behaving browser, not by a maliciously crafted script... We need a safer way to know which fields have been *explicitlly* disabled by the server-side application.

Then, what we could do is adding
something like an attribute "can_be_disabled" (of course a better name is needed) to the validator and that will be processed before the is_empty / not_empty attributes. If the widget "can_be_disabled" and isn't there, then
skip its validator.

Hmmm, I don't think that's a good idea because, for example, maybe a validation spec states that fields A and B can only be disabled if they're disabled simultaneously, this means we need to place that logic in a FormValidator which has access to all fields (or use the state parameter), not under simple validators.


I believe that this could be applied to schemas as well...
Hehe, I thought colds were something you forgot about in when living in
sunny Brazil... ;)

The problem is that I live in a place where we have all four seasons of the year every day... :-\ (Curitiba, at Paraná state). There's even a joke here: "Do you know what comes after two rainy days in Curitiba? --- Monday!"

I must be working too much and my body must be too weak... This is not the first cold that I get that puts me down for a while. Time to rethink what
I've been doing with myself.
But I bet that a Spanish guy would be fine here... Except that we can't offer
the 41 or 42 celsius degrees you get at noon at Plaza de España in
Madrid... ;-) (BTW, there's a nice coffee shopp there where I drunk iced
coffee for the first time... ;-))

Nor the 5 degrees celsius near Plaza Mayor right now... :P

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