Changeset 28 for trunk/change.py

Show
Ignore:
Timestamp:
26/11/07 20:14:17 (4 years ago)
Author:
daedalus
Message:

* Refactored code to permit more flexible templating of changes. You can now

define a <changetemplate/> in 95% the same way as a <change/>, and then
refer to a <changetemplate/> when defining a <change/> to allow you to
combine change templates as a change flow, using namespaces and iterators
for each one.

* Some work on manual bailout in authoritarian mode, but it isn't completely

bailing out immediately yet, due to some complexities in the deferred chains
that I haven't quite unravelled.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/change.py

    r27 r28  
    215215        return '<%s: %s>' % ( self.__class__, self.name ) 
    216216 
     217    def copy(self): 
     218        """ 
     219        Create a copy of myself. 
     220        """ 
     221        newchange = CommandChange('Copy of %s' % self.name, 
     222                                  self.devices, 
     223                                  self.serial_mode, 
     224                                  self.backout_all, 
     225                                  self.on_fail_continue, 
     226                                  self.on_fail_retry, 
     227                                  self.max_retries, 
     228                                  self.pre_impl, 
     229                                  self.impl, 
     230                                  self.post_impl, 
     231                                  self.pre_backout, 
     232                                  self.backoutset, 
     233                                  self.post_backout, 
     234                                  self.pre_requisites, 
     235                                  ) 
     236 
     237        # set the namespace as a copy of mine 
     238        if self.namespace is not None: 
     239            newchange.namespace = self.namespace.copy() 
     240            pass 
     241 
     242        return newchange 
     243         
    217244    def set_state(self, state_string): 
    218245        self.state = CHANGE_STATE[state_string] 
     
    236263                for ns in self.iterator: 
    237264                    log.debug("Adding namespace entry of: %s", ns) 
    238                     # FIXME: This permanently updates the namespace. 
    239                     # Should we be updating a local copy? 
     265 
     266                    # Make sure we only update a copy, so that this 
     267                    # update isn't permanent 
    240268                    newnamespace = ns.copy() 
    241269                    newnamespace.update(namespace)