Changes between Version 6 and Version 7 of TestManagerForTracPluginGenericClass


Ignore:
Timestamp:
Jan 4, 2011 10:03:06 PM (4 years ago)
Author:
seccanj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TestManagerForTracPluginGenericClass

    v6 v7  
    7070See below the !GenericClassModelProvider to see how to make the framework create the required tables declaratively. 
    7171 
     72[[BR]] 
    7273== How to create a custom persistent object == 
    7374 
     
    360361 
    361362[[BR]] 
     363=== Keeping control of your objects === 
     364 
     365We have seen how easy is to define a class and its properties, and below we will see how easy it is to then use these classes in the client code. 
     366 
     367The framework will handle all of the burden of fetching the database rows, populating the object, keeping track of the changes, saving it when you want to, and so on.  
     368 
     369Anyway, there may be cases where you want to keep control on what's being done, and perhaps prevent some of these operations to occur, based on your own logic. 
     370 
     371This can be easily achieved by overriding some methods: 
     372 * The "pre" methods get called before performing the corresponding operation. You can return True or False to allow, or deny, the operation to be performed, respectively. 
     373 * The "post" methods get called after the corresponding operation has been performed, before the transaction is committed. They give you the opportunity to perform further custom work in the context of the same operation. 
     374 
     375The following is the list of such methods, from the !AbstractVariableFieldsObject class documentation. 
     376 
     377{{{ 
     378    def pre_fetch_object(self, db): 
     379        """  
     380        Use this method to perform initialization before fetching the 
     381        object from the database. 
     382        Return False to prevent the object from being fetched from the  
     383        database. 
     384        """ 
     385        return True 
     386 
     387    def post_fetch_object(self, db): 
     388        """ 
     389        Use this method to further fulfill your object after being 
     390        fetched from the database. 
     391        """ 
     392        pass 
     393         
     394    def pre_insert(self, db): 
     395        """  
     396        Use this method to perform work before inserting the 
     397        object into the database. 
     398        Return False to prevent the object from being inserted into the  
     399        database. 
     400        """ 
     401        return True 
     402 
     403    def post_insert(self, db): 
     404        """ 
     405        Use this method to perform further work after your object has 
     406        been inserted into the database. 
     407        """ 
     408        pass 
     409         
     410    def pre_save_changes(self, db): 
     411        """  
     412        Use this method to perform work before saving the object changes 
     413        into the database. 
     414        Return False to prevent the object changes from being saved into  
     415        the database. 
     416        """ 
     417        return True 
     418 
     419    def post_save_changes(self, db): 
     420        """ 
     421        Use this method to perform further work after your object  
     422        changes have been saved into the database. 
     423        """ 
     424        pass 
     425         
     426    def pre_delete(self, db): 
     427        """  
     428        Use this method to perform work before deleting the object from  
     429        the database. 
     430        Return False to prevent the object from being deleted from the  
     431        database. 
     432        """ 
     433        return True 
     434 
     435    def post_delete(self, db): 
     436        """ 
     437        Use this method to perform further work after your object  
     438        has been deleted from the database. 
     439        """ 
     440        pass 
     441         
     442    def pre_save_as(self, old_key, new_key, db): 
     443        """  
     444        Use this method to perform work before saving the object with 
     445        a different identity into the database. 
     446        Return False to prevent the object from being saved into the  
     447        database. 
     448        """ 
     449        return True 
     450         
     451    def post_save_as(self, old_key, new_key, db): 
     452        """ 
     453        Use this method to perform further work after your object  
     454        has been saved into the database. 
     455        """ 
     456        pass 
     457         
     458    def pre_list_matching_objects(self, db): 
     459        """  
     460        Use this method to perform work before finding matches in the  
     461        database. 
     462        Return False to prevent the search. 
     463        """ 
     464        return True 
     465}}} 
     466 
     467[[BR]] 
    362468== A sample use == 
    363469