[Laszlo-dev] Construct methods and attribute predicates [Was: Didn't you report a bug about _instanceAttrs and states?]
Henry Minsky
hminsky at laszlosystems.com
Sun Jan 11 11:35:05 PST 2009
>> There are likely even more aspects which make clear that setAttribute
>> isn't a good candidate for such stuff.
>
> Yes, you are exactly right here. So, there needs to be some other interface
> for removing a constraint on an attribute.
>
> It sounds like __LZhasConstraint (or something like it) should be made
> public. Perhaps it should return the constraint method name when an
> attribute is constrained, so you can use removeConstraintMethod to remove
> the constraint if you want to override it?
I think that having an API to tell if a constraint exists might be the
best solution for now.
Question, what happens if someone has two or more different
constraints which set the same attribute? I guess that would be an app
design bug, no? Or at least a bad idea?
If you can manually remove find and remove a constraint, and can tell
if the user explicitly supplied an attribute value, then your class
can decide whether to use the default constraint or override it with a
constant value.
I guess the only way to tell if an arg is supplied explicitly, is to
use the idiom you had where the construct() method looks for the
attribute name in the args list, e.g., args['x']?
Henry Minsky
Software Architect
hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list