[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1579] trunk/py/scripts/addons/modules/ extensions_framework/__init__.py: extensions_framework: changed ef_initialise_properties function to not register the class with RNA , added another function ef_register_initialise_properties that does both.

Doug Hammond doughammond at hamsterfight.co.uk
Fri Feb 11 10:29:55 CET 2011


Revision: 1579
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1579
Author:   dougal2
Date:     2011-02-11 09:29:54 +0000 (Fri, 11 Feb 2011)
Log Message:
-----------
extensions_framework: changed ef_initialise_properties function to not register the class with RNA, added another function ef_register_initialise_properties that does both.

Modified Paths:
--------------
    trunk/py/scripts/addons/modules/extensions_framework/__init__.py

Modified: trunk/py/scripts/addons/modules/extensions_framework/__init__.py
===================================================================
--- trunk/py/scripts/addons/modules/extensions_framework/__init__.py	2011-02-11 03:40:27 UTC (rev 1578)
+++ trunk/py/scripts/addons/modules/extensions_framework/__init__.py	2011-02-11 09:29:54 UTC (rev 1579)
@@ -116,16 +116,13 @@
 			continue
 
 def ef_initialise_properties(cls):
-	"""This is mostly copied from plugin.plugin.install
-	This is a class decorator that should be used on
+	"""This is a class decorator that should be used on
 	sub-classes of declarative_property_group in order
 	to ensure that they are initialised when the addon
 	is loaded.
 	
 	"""
 	
-	bpy.utils.register_class(cls)
-	
 	for property_group_parent in cls.ef_attach_to:
 		if property_group_parent is not None:
 			prototype = getattr(bpy.types, property_group_parent)
@@ -142,6 +139,17 @@
 	
 	return cls
 
+def ef_register_initialise_properties(cls):
+	"""As ef_initialise_properties, but also registers the
+	class with RNA. Note that this isn't a great idea
+	because it's non-trivial to unregister the class, unless
+	you keep track of it yourself.
+	"""
+	
+	bpy.utils.register_class(cls)
+	ef_initialise_properties(cls)
+	return cls
+
 class declarative_property_group(bpy.types.IDPropertyGroup):
 	"""A declarative_property_group describes a set of logically
 	related properties, using a declarative style to list each



More information about the Bf-extensions-cvs mailing list