From 99b8ef09b954c69492be95b68989d6d75b0446ee Mon Sep 17 00:00:00 2001
From: Håkon Vågsether <haakonsv@gmail.com>
Date: Wed, 29 Aug 2018 17:25:11 +0200
Subject: grc: Fix problems with option_attributes

Enabling the option_attributes to be accessed by the rest of the
block's parameters by using a new string subtype. Also adding
validation.
---
 grc/core/params/param.py | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'grc/core/params/param.py')

diff --git a/grc/core/params/param.py b/grc/core/params/param.py
index ce40025228..69aa6fd811 100644
--- a/grc/core/params/param.py
+++ b/grc/core/params/param.py
@@ -31,6 +31,7 @@ from ..utils.descriptors import Evaluated, EvaluatedEnum, setup_names
 from . import dtypes
 from .template_arg import TemplateArg
 
+attributed_str = type('attributed_str', (str,), {})
 
 @setup_names
 class Param(Element):
@@ -178,6 +179,10 @@ class Param(Element):
         # ID and Enum types (not evaled)
         #########################
         if dtype in ('id', 'stream_id') or self.is_enum():
+            if self.options.attributes:
+                expr = attributed_str(expr)
+                for key, value in self.options.attributes[expr].items():
+                    setattr(expr, key, value)
             return expr
 
         #########################
-- 
cgit v1.2.3