Example #1
0
class Key(BaseMixin, TimestampMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(length=255), nullable=False, unique=True)
    # IPv4 addresses are a maximum of 15 chars
    description = db.Column(db.Text, nullable=False)
    type = db.Column(db.Enum(*TYPES.keys()), nullable=False)
    data = db.relationship('Datum', backref='key', lazy='dynamic')

    def __repr__(self):
        return "<Key(name=%s, type=%s)>" % (self.name, self.type)
Example #2
0
 def value(self, value):
     converter = TYPES.get(self.key.type)
     self._value = str(converter(value))
Example #3
0
 def value(self):
     converter = TYPES.get(self.key.type)
     return converter(self._value)
Example #4
0
 def value(self, value):
     converter = TYPES.get(self.key.type)
     self._value = str(converter(value))
Example #5
0
 def value(self):
     converter = TYPES.get(self.key.type)
     return converter(self._value)