Logo Search packages:      
Sourcecode: qa-assistant version File versions  Download package

def properties::Properties::__setitem__ (   self,
  key,
  value 
)

Set a property to a value.

Override the default method so that we can do these special things:
1) create new values when passed an entire PropEntry.
2) If we are only passed a value for the PropEntry, set the
   indicated Property's value if it exists.
   (If it doesn't exist, and you want to be able to set it, you need
    to first add it by passing in a complete PropEntry struct.)
3) When a property is set, check if there are any functions that need
   to be called when that happens.

Definition at line 68 of file properties.py.

00068                                      :
        '''Set a property to a value.

        Override the default method so that we can do these special things:
        1) create new values when passed an entire PropEntry.
        2) If we are only passed a value for the PropEntry, set the
           indicated Property's value if it exists.
           (If it doesn't exist, and you want to be able to set it, you need
            to first add it by passing in a complete PropEntry struct.)
        3) When a property is set, check if there are any functions that need
           to be called when that happens.
        '''
        if isinstance(value, PropEntry):
            self.storage[key] = value
            self._sortedKeys.append(key)
        else:
            try:
                attrib = self[key]
            except KeyError:
                raise KeyError, (
                        'This checklist has no %s Property' % (key))
            attrib.value = value

        # Let everyone know a property has changed
        self.emit('changed', key)
        # If the property has a function attached to it, run it.
        if self[key].functions:
            for function in self[key].functions:
                exec('self.functions.' + function + '()')

        # Check whether the properties have been completely filled out
        if self._requirementsMet and self[key].propType == 'onload' and not (
                self[key].value or self[key].value == 0):
            self._requirementsMet = False

    def keys(self):


Generated by  Doxygen 1.6.0   Back to index