def persistCollInit(self, method, ctrlName, propName, params={}): collInitParse = methodparse.CollectionInitParse( None, '[]', method, [], propName) self.parentCompanion.textConstr.params = { 'choices': collInitParse.asText() } self.designer.addCollToObjectCollection(collInitParse)
def initObjProps(self, props, name, creator, dependents, depLinks): """ Initialise property list by evaluating 1st parameter and calling prop's setter with it. Also associate companion name with prop parse objs """ # XXX creator not used if props.has_key(name): comp, ctrl = self.objects[name][0:2] # initialise live component's properies for prop in props[name]: prop.prop_name = comp.getPropNameFromSetter(prop.prop_setter) # Dependent properties if prop.prop_name in comp.dependentProps(): self.addDepLink(prop, name, dependents, depLinks) # Collection initialisers elif len(prop.params) and prop.params[0][:11] == 'self._init_': collItem = methodparse.CollectionInitParse(prop.params[0]) self.addCollView(name, collItem.method, False) # Check for custom evaluator elif comp.customPropEvaluators.has_key(prop.prop_name): args = comp.customPropEvaluators[prop.prop_name]( prop.params, self.getAllObjects()) # XXX This is a hack !!! # XXX argument list with more than one prop value are # XXX initialised thru the companion instead of the control if prop.prop_name in comp.initPropsThruCompanion: getattr(comp, prop.prop_setter)(*(args, )) else: getattr(ctrl, prop.prop_setter)(*args) # Check for pops which don't update the control elif prop.prop_name in comp.onlyPersistProps(): continue # Normal property, eval value and apply it else: try: value = PaletteMapping.evalCtrl( prop.params[0], self.model.specialAttrs) except AttributeError, name: value = PaletteMapping.evalCtrl( prop.params[0], {'self': self.controllerView.objectNamespace}) except: print _('Problem with: %s') % prop.asText() raise