[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35659] trunk/blender/release/scripts/ modules/bpy/utils.py: patch from Martin, call classes register/ unregister functions.

Campbell Barton ideasman42 at gmail.com
Mon Mar 21 07:22:10 CET 2011


Revision: 35659
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35659
Author:   campbellbarton
Date:     2011-03-21 06:22:09 +0000 (Mon, 21 Mar 2011)
Log Message:
-----------
patch from Martin, call classes register/unregister functions.
Modified to only do one lookup.

from Martin: 
 "Basically, what it does is allow you to add register and unregister class methods to rna types, this way you don't have to rely on module register/unregister methods to setup your types properly (and it makes them easier to move around when reorganizing code and easier to understand what a type does when reading code). This is especially nice for PropertyGroup classes that are added as properties to existing types, you can easily see in their register methods where they are added and removed in their unregister method. Obviously, those two methods are optional, so current code still works fine."

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/utils.py

Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py	2011-03-21 03:22:33 UTC (rev 35658)
+++ trunk/blender/release/scripts/modules/bpy/utils.py	2011-03-21 06:22:09 UTC (rev 35659)
@@ -436,6 +436,9 @@
             print("    %r" % cls)
         try:
             register_class(cls)
+            cls_func = getattr(cls, "register", None)
+            if cls_func is not None:
+                cls_func()
         except:
             print("bpy.utils.register_module(): failed to registering class %r" % cls)
             print("\t", path, "line", line)
@@ -455,6 +458,9 @@
             print("    %r" % cls)
         try:
             unregister_class(cls)
+            cls_func = getattr(cls, "unregister", None)
+            if cls_func is not None:
+                cls_func()
         except:
             print("bpy.utils.unregister_module(): failed to unregistering class %r" % cls)
             print("\t", path, "line", line)




More information about the Bf-blender-cvs mailing list