summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ebus/web/model.py10
-rw-r--r--test.py13
2 files changed, 15 insertions, 8 deletions
diff --git a/ebus/web/model.py b/ebus/web/model.py
index 04b15ed..7e21e82 100644
--- a/ebus/web/model.py
+++ b/ebus/web/model.py
@@ -41,8 +41,8 @@ class Value(ModelBase):
def value(self):
raise NotImplementedException()
-class ValueInt(Value):
- __mapper_args__ = {'polymorphic_identity': 'value'}
+class ValueFloat(Value):
+ __mapper_args__ = {'polymorphic_identity': 'float'}
value_float = Column(Float(precision=4))
def __init__(self, sensor, value, timestamp=datetime.now()):
@@ -53,7 +53,7 @@ class ValueInt(Value):
return self.value_float
class ValueInt(Value):
- __mapper_args__ = {'polymorphic_identity': 'value'}
+ __mapper_args__ = {'polymorphic_identity': 'int'}
value_int = Column(Integer)
def __init__(self, sensor, value, timestamp=datetime.now()):
@@ -64,12 +64,12 @@ class ValueInt(Value):
return self.value_int
class ValueString(Value):
- __mapper_args__ = {'polymorphic_identity': 'value'}
+ __mapper_args__ = {'polymorphic_identity': 'string'}
value_string = Column(String)
def __init__(self, sensor, value, timestamp=datetime.now()):
Value.__init__(self, sensor, timestamp)
- self.value_int = value
+ self.value_string = value
def value(self):
return self.value_string
diff --git a/test.py b/test.py
index 82df5b6..958c7b1 100644
--- a/test.py
+++ b/test.py
@@ -17,11 +17,18 @@ session = Session()
t1_sensor = model.Sensor("foosensor", "blatest")
session.add(t1_sensor)
-for i in xrange(10000):
- session.add( model.Value(t1_sensor, 0.5) )
+for i in xrange(10):
+ m = model.ValueInt(t1_sensor, 1)
+ session.add( m )
-session.commit()
+ m = model.ValueFloat(t1_sensor, 1.2)
+ session.add( m )
+
+ m = model.ValueString(t1_sensor, "foobar")
+ session.add( m )
+
+session.commit()
session.close()