Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hammond <doughammond@hamsterfight.co.uk>2011-02-11 02:13:59 +0300
committerDoug Hammond <doughammond@hamsterfight.co.uk>2011-02-11 02:13:59 +0300
commit6b5ccf85a107fbce7b63b1875fb645d3d6ed32f5 (patch)
treededab5089dac5f0adf26b0548ed8c8a4727498df /modules
parent4d24ac5ca09e45b3afb6873ddfdf3530ff98f097 (diff)
extensions_framework: added ef_initialise_properties class decorator to initialise declarative_property_groups at declaration time instead of requiring a potentially huge class list in the addon __init__ file
Diffstat (limited to 'modules')
-rw-r--r--modules/extensions_framework/__init__.py33
-rw-r--r--modules/extensions_framework/plugin.py2
2 files changed, 34 insertions, 1 deletions
diff --git a/modules/extensions_framework/__init__.py b/modules/extensions_framework/__init__.py
index 08bd57e7..f842f5ae 100644
--- a/modules/extensions_framework/__init__.py
+++ b/modules/extensions_framework/__init__.py
@@ -115,6 +115,30 @@ def init_properties(obj, props, cache=True):
# Silently skip invalid entries in props
continue
+def ef_initialise_properties(cls):
+ """This is mostly copied from plugin.plugin.install
+ 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.
+
+ """
+
+ for property_group_parent in cls.ef_attach_to:
+ if property_group_parent is not None:
+ prototype = getattr(bpy.types, property_group_parent)
+ if not hasattr(prototype, cls.__name__):
+ init_properties(prototype, [{
+ 'type': 'pointer',
+ 'attr': cls.__name__,
+ 'ptype': cls,
+ 'name': cls.__name__,
+ 'description': cls.__name__
+ }])
+
+ init_properties(cls, cls.properties)
+
+ return cls
class declarative_property_group(bpy.types.IDPropertyGroup):
"""A declarative_property_group describes a set of logically
@@ -135,6 +159,15 @@ class declarative_property_group(bpy.types.IDPropertyGroup):
"""
+ """This property tells extensions_framework which bpy.type(s)
+ to attach this IDPropertyGroup to. If left as an empty list,
+ it will not be attached to any type, but its properties will
+ still be initialised. The type(s) given in the list should be
+ a string, such as 'Scene'.
+
+ """
+ ef_attach_to = []
+
"""This list controls the order of property layout when rendered
by a property_group_renderer. This can be a nested list, where each
list becomes a row in the panel layout. Nesting may be to any depth.
diff --git a/modules/extensions_framework/plugin.py b/modules/extensions_framework/plugin.py
index 27b45871..a548a84f 100644
--- a/modules/extensions_framework/plugin.py
+++ b/modules/extensions_framework/plugin.py
@@ -82,7 +82,7 @@ class plugin(object):
if call_init:
init_properties(property_group, property_group.properties)
- log('Extension "%s" initialised' % r_class.bl_label)
+ log('Extension "%s" initialised' % r_class.__name__)
@classmethod
def uninstall(r_class):