Changes between Version 7 and Version 8 of TestManagerForTracPluginGenericClass


Ignore:
Timestamp:
Jan 4, 2011, 9:50:41 PM (13 years ago)
Author:
Roberto Longobardi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TestManagerForTracPluginGenericClass

    v7 v8  
    580580}}}
    581581
     582=== Saving an object with a new name (key) ===
     583
     584Sometimes all your Users want is to use an existing object, modify a couple of things and save it under another name.
     585
     586To help your code with this task, the abstract class provide the {{{save_as()}}} method.
     587
     588The previous object is not deleted, so if needed it must be deleted explicitly.
     589
     590See the following code:
     591
     592{{{
     593    rws = ResourceWorkflowState(self.env, id, sometext)
     594   
     595    if rws.exists:
     596        # The object already exists.
     597        # Now we want to duplicate it, by giving the object a different key and saving it.
     598        # The following code will save the new object into the database and also call all
     599        # of the registered listeners.
     600        try:
     601            new_key = {'id': '123456', 'res_realm': rws['res_realm']}
     602            rws['state'] = 'new'
     603            rws.save_as(new_key)
     604        except:
     605            self.log.info("Error saving the resource with id %s" % new_key['id'])
     606}}}
     607
     608=== Getting or setting multiple values at the same time ===
     609
     610A couple of utility methods in the base class allow clients to get or get multiple values at the same time.
     611
     612See the following code for details.
     613
     614{{{
     615    def get_values(self, prop_names):
     616        """
     617        Returns a list of the values for the specified properties,
     618        in the same order as the property names.
     619        """
     620               
     621    def set_values(self, props):
     622        """
     623        Sets multiple properties into this object.
     624        props must be a dictionary object with the names and values to set.       
     625       
     626        Note: this method does not keep history of property changes.
     627        """
     628}}}
     629
     630[[BR]]
     631== Trac Resource coupling ==
     632
     633Every object managed within this framework is paired with a Trac Resource.
     634
     635TODO: Fill in this section.
     636
    582637[[BR]]
    583638== Providing specific results to the Trac search engine ==