[storm] another question regarding inserts
Adrian Klaver
aklaver at comcast.net
Wed Aug 8 00:33:28 BST 2007
On Tuesday 07 August 2007 4:00 pm, shawn bright wrote:
> ok, here is my new function:
> def make_history(obj, function, s_time = 'none', sid='none',
> switch='none'): print '\n\n make history'
> print 'found object %s' % obj.monitor
> print 'found raw = %s' % obj.last_raw
> print 'type of raw = %s' % type(obj.last_raw)
> print 'found value = %s ' % obj.last_value
> store = Store.of(obj)
> raw = float(obj.last_raw)
> hit = HistoryHit()
> hit.monitor = obj.monitor
> hit.raw = raw
> hit.value = unicode(obj.last_value)
> hit.function = unicode(function)
> if s_time == 'none': hit.s_date_time = datetime.datetime.now()
> hit.date_time = datetime.datetime.now()
> hit.sid, hit.switch = unicode(sid), unicode(switch)
> store.add(hit)
>
> the print statments show me that in my test, the raw was a type float
> before the line that makes it one.
> but i left the line that makes it a float in there anyway.
> raw = float(hit.raw)
Alright, I am now officially lost. Where did this line come from? I see raw =
float(obj.last_raw) but not raw = float(hit.raw).
> then later
> hit.raw = raw
>
> but still, the only thing showing up in the history table is 0 ( the
> default )
> and the DEBUG of the sql statement is still missing the raw as part of what
> gets
> INSERT INTO history..
>
> thanks
> shawn
>
I am still working out the semantics of storm so I am not sure what store =
Store.of(obj) does and how that affects the store.add(hit) call later. If it
where me I would try store=Store(). Also we are not seeing all the code and
in your examples you call self.store before running make_history so it is
entirely possible you need to drop the store assignment and just do
self.store.add(hit). Something else comes to mind, in your examples you
assign to hit for values going to StatusHit() and for values going to
HistoryHit(). Having wrestled with name visibility before, I generally try to
create different names to make it easier to sort out where my values are
originating from i.e. status_hit,history_hit
Good luck,
--
Adrian Klaver
aklaver at comcast.net
More information about the storm
mailing list