diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-10-02 22:24:56 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-10-02 22:24:56 (GMT) |
commit | cf40c1951f4f0f26090226fb4969ca147341a031 (patch) | |
tree | b3bb17043645aff11a93940eba90d7488bcebf45 /tutorius/properties.py | |
parent | 09b2ea3369df967309f030f9196c2f9861bc1b2c (diff) |
LP 439980 : Refactored the XMLSerializer to support complex components; Corrected specs for the addons properties and constructor parameters names; Moved all existing actions and events to components (except a few left in code for testing purposes)
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r-- | tutorius/properties.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py index abf76e5..6d30a8d 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -95,6 +95,39 @@ class TPropContainer(object): """ return object.__getattribute__(self, "_props").keys() + def is_identical(self, otherContainer): + for prop in self._props.keys(): + found = False + for otherProp in otherContainer._props.keys(): + if prop == otherProp: + this_type = getattr(type(self), prop).type + other_type = getattr(type(otherContainer), prop).type + if this_type != other_type: + return False + if this_type == "addonlist": + for inner_cont in self._props[prop]: + inner_found = False + for other_inner in otherContainer._props[prop]: + if inner_cont.is_identical(other_inner): + inner_found = True + break + if inner_found == False: + return False + found = True + break + elif this_type == "addon": + if not self._props[prop].is_identical(otherContainer._props[prop]): + return False + found = True + break + else: + if self._props[prop]== otherContainer._props[prop]: + found = True + break + if found == False: + return False + return True + class TutoriusProperty(object): """ The base class for all actions' properties. The interface is the following : @@ -317,8 +350,15 @@ class TAddonListProperty(TutoriusProperty): See TAddonProperty """ def __init__(self): - super(TAddonProperty, self).__init__() + TutoriusProperty.__init__(self) self.type = "addonlist" self.default = [] + def validate(self, value): + if isinstance(value, list): + for component in value: + if not (isinstance(component, TPropContainer)): + raise ValueError("Expected a list of TPropContainer instances inside TAddonListProperty value, got a %s" % (str(type(component)))) + return value + raise ValueError("Value proposed to TAddonListProperty is not a list") |