Removed view saving stuff and added uuid

* the viewer should save any view params, not the segment (there might be multiple views, for instance!)
* viewer can reference uuid as key into view params dictionary
This commit is contained in:
Rob McMullen 2017-02-21 11:22:31 -08:00
parent a34dc24aeb
commit 0ba5c8546c

View File

@ -1,5 +1,6 @@
import bisect import bisect
import cStringIO import cStringIO
import uuid
import numpy as np import numpy as np
@ -235,8 +236,7 @@ class DefaultSegment(object):
self.verbose_name = verbose_name self.verbose_name = verbose_name
self.page_size = -1 self.page_size = -1
self.map_width = 40 self.map_width = 40
self.cursor_save = -1 self.uuid = str(uuid.uuid4())
self.index_of_first_visible = -1
def set_raw(self, rawdata): def set_raw(self, rawdata):
self.rawdata = rawdata self.rawdata = rawdata
@ -249,7 +249,7 @@ class DefaultSegment(object):
def __getstate__(self): def __getstate__(self):
state = dict() state = dict()
for key in ['start_addr', 'error', 'name', 'verbose_name', 'page_size', 'map_width', 'cursor_save', 'index_of_first_visible']: for key in ['start_addr', 'error', 'name', 'verbose_name', 'page_size', 'map_width', 'uuid']:
state[key] = getattr(self, key) state[key] = getattr(self, key)
r = self.rawdata r = self.rawdata
state['_rawdata_bounds'] = list(r.byte_bounds_offset()) state['_rawdata_bounds'] = list(r.byte_bounds_offset())
@ -267,10 +267,8 @@ class DefaultSegment(object):
The use of jsonpickle to recreate objects doesn't go through __init__, The use of jsonpickle to recreate objects doesn't go through __init__,
so newer attributes won't exist. so newer attributes won't exist.
""" """
if not hasattr(self, 'cursor_save'): if not hasattr(self, 'uuid'):
self.cursor_save = -1 self.uuid = str(uuid.uuid4())
if not hasattr(self, 'index_of_first_visible'):
self.index_of_first_visible = -1
def reconstruct_raw(self, rawdata): def reconstruct_raw(self, rawdata):
start, end = self._rawdata_bounds start, end = self._rawdata_bounds