# Path: monitoring/alarmdefs/constants.py
# URL_PREFIX = 'horizon:monitoring:alarmdefs:'
# TEMPLATE_PREFIX = 'monitoring/alarmdefs/'


from itertools import chain
from django.template.loader import get_template
from django.utils.translation import ugettext as _  # noqa
from horizon import exceptions
from horizon import forms
from horizon import messages
from monitoring.alarmdefs import constants
from monitoring import api
import json

        local_attrs = {
            'func': ExpressionWidget.func,
            'comparators': ExpressionWidget.comparators,
            'operators': ExpressionWidget.operators,
            'metrics': self.metrics
        }

        local_attrs.update(final_attrs)
        return t.render(local_attrs)


class ExpressionField(forms.CharField):

    def _get_metrics(self):
        return self._metrics

    def _set_metrics(self, value):
        self._metrics = self.widget.metrics = value

    metrics = property(_get_metrics, _set_metrics)


class MatchByWidget(forms.Widget):
    def __init__(self, initial, attrs=None):
        super(MatchByWidget, self).__init__(attrs)
        self.initial = initial

    def render(self, name, value, attrs=None, renderer=None):
        final_attrs = self.build_attrs(attrs, {'name': name})

# Path: monitoring/alarmdefs/constants.py
# URL_PREFIX = 'horizon:monitoring:alarmdefs:'
# TEMPLATE_PREFIX = 'monitoring/alarmdefs/'


# Path: monitoring/alarmdefs/forms.py
from itertools import chain
from django.template.loader import get_template
from django.utils.translation import ugettext as _  # noqa
from horizon import exceptions
from horizon import forms
from horizon import messages
from monitoring.alarmdefs import constants
from monitoring import api
import json


        local_attrs = {
            'func': ExpressionWidget.func,
            'comparators': ExpressionWidget.comparators,
            'operators': ExpressionWidget.operators,
            'metrics': self.metrics
        }

        local_attrs.update(final_attrs)
        return t.render(local_attrs)


class ExpressionField(forms.CharField):

    def _get_metrics(self):
        return self._metrics

    def _set_metrics(self, value):
        self._metrics = self.widget.metrics = value

    metrics = property(_get_metrics, _set_metrics)


class MatchByWidget(forms.Widget):
    def __init__(self, initial, attrs=None):
        super(MatchByWidget, self).__init__(attrs)
        self.initial = initial

    def render(self, name, value, attrs=None, renderer=None):
        final_attrs = self.build_attrs(attrs, {'name': name})

        t = get_template(constants.TEMPLATE_PREFIX + 'match_by_field.html')