# Path: lingobarter/core/db.py



import json
from flask.ext.babelex import lazy_gettext
from lingobarter.core.db import db
        return self.FORMATTERS.get(self.formatter,
                                   self.DEFAULT_FORMATTER)(self.rawvalue)

    @value.setter
    def value(self, value):
        self.rawvalue = self.REVERSE_FORMATTERS.get(self.formatter,
                                                    self.STR_FORMATTER)(value)

    def clean(self):
        try:
            # see property annotation above, value will be an unicode string,
            # instead of a function
            self.value
        except Exception as e:
            # raise base exception because Flask-Admin can't handle the output
            # for some specific Exceptions of Mongoengine
            raise Exception(e.message)
        super(CustomValue, self).clean()

    def __unicode__(self):
        return u"{s.name} -> {s.value}".format(s=self)


class HasCustomValue(object):
    values = db.ListField(db.EmbeddedDocumentField(CustomValue))

    def get_values_tuple(self):
        return [(value.name, value.value, value.formatter)
                for value in self.values]


# Path: lingobarter/core/db.py



# Path: lingobarter/core/models/custom_values.py
import json
from flask.ext.babelex import lazy_gettext
from lingobarter.core.db import db

        return self.FORMATTERS.get(self.formatter,
                                   self.DEFAULT_FORMATTER)(self.rawvalue)

    @value.setter
    def value(self, value):
        self.rawvalue = self.REVERSE_FORMATTERS.get(self.formatter,
                                                    self.STR_FORMATTER)(value)

    def clean(self):
        try:
            # see property annotation above, value will be an unicode string,
            # instead of a function
            self.value
        except Exception as e:
            # raise base exception because Flask-Admin can't handle the output
            # for some specific Exceptions of Mongoengine
            raise Exception(e.message)
        super(CustomValue, self).clean()

    def __unicode__(self):
        return u"{s.name} -> {s.value}".format(s=self)


class HasCustomValue(object):
    values = db.ListField(db.EmbeddedDocumentField(CustomValue))

    def get_values_tuple(self):
        return [(value.name, value.value, value.formatter)
                for value in self.values]


    def get_value(self, name, default=None):