From 451a32070cecf391e158baa9551cf739a5777ce0 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 8 May 2013 15:40:51 +0000 Subject: [PATCH] Removed the unused socket template system from the bpy_types Node base class (it interferes with the input_templates/output_templates functions from C nodes). This can be reimplemented in a nicer way for pynode subclasses later on, but should not be part of the basic Node class. --- release/scripts/modules/bpy_types.py | 95 +--------------------------- 1 file changed, 1 insertion(+), 94 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 204a9bcd261..a4080b673db 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -752,100 +752,7 @@ class NodeTree(bpy_types.ID, metaclass=RNAMetaPropGroup): __slots__ = () -class NodeSocketTemplate(): - type = 'UNDEFINED' - - # Default implementation: - # Create a single property using the socket template's 'value_property' attribute - # value_property should be created in the __init__ function - # - # If necessary this function can be overloaded in subclasses, e.g. to create multiple value properties - def define_node_properties(self, node_type, prefix): - if hasattr(self, "value_property"): - setattr(node_type, prefix+"value", self.value_property) - - def init_socket(self, socket): - socket.type = self.type - if hasattr(self, "value_property"): - socket.value_property = self.value_property[1]['attr'] - - -def gen_valid_identifier(seq): - # get an iterator - itr = iter(seq) - # pull characters until we get a legal one for first in identifer - for ch in itr: - if ch == '_' or ch.isalpha(): - yield ch - break - # pull remaining characters and yield legal ones for identifier - for ch in itr: - if ch == '_' or ch.isalpha() or ch.isdigit(): - yield ch - - -def sanitize_identifier(name): - return ''.join(gen_valid_identifier(name)) - - -def unique_identifier(name, identifier_list): - # First some basic sanitation, to make a usable identifier string from the name - base = sanitize_identifier(name) - # Now make a unique identifier by appending an unused index - identifier = base - index = 0 - while identifier in identifier_list: - index += 1 - identifier = base + str(index) - return identifier - - -class RNAMetaNode(RNAMetaPropGroup): - def __new__(cls, name, bases, classdict, **args): - # Wrapper for node.init, to add sockets from templates - - def create_sockets(self): - inputs = getattr(self, 'input_templates', None) - if inputs: - for temp in inputs: - socket = self.inputs.new(type=temp.bl_socket_idname, name=temp.name, identifier=temp.identifier) - temp.init_socket(socket) - outputs = getattr(self, 'output_templates', None) - if outputs: - for temp in outputs: - socket = self.outputs.new(type=temp.bl_socket_idname, name=temp.name, identifier=temp.identifier) - temp.init_socket(socket) - - init_base = classdict.get('init', None) - if init_base: - def init_node(self, context): - create_sockets(self) - init_base(self, context) - else: - def init_node(self, context): - create_sockets(self) - - classdict['init'] = init_node - - # Create the regular class - result = RNAMetaPropGroup.__new__(cls, name, bases, classdict) - - # Add properties from socket templates - inputs = classdict.get('input_templates', None) - if inputs: - for i, temp in enumerate(inputs): - temp.identifier = unique_identifier(temp.name, [t.identifier for t in inputs[0:i]]) - temp.define_node_properties(result, "input_"+temp.identifier+"_") - outputs = classdict.get('output_templates', None) - if outputs: - for i, temp in enumerate(outputs): - temp.identifier = unique_identifier(temp.name, [t.identifier for t in outputs[0:i]]) - temp.define_node_properties(result, "output_"+temp.identifier+"_") - - return result - - -class Node(StructRNA, metaclass=RNAMetaNode): +class Node(StructRNA, metaclass=RNAMetaPropGroup): __slots__ = () @classmethod