Skip to content

Commit

Permalink
Re-use code from glue-core whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Aug 16, 2024
1 parent 70b3e74 commit b7e5392
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions glue_jupyter/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,13 @@ def restore_session(path):
os.chdir(start_dir)

def __gluestate__(self, context):
viewers = [context.id(v) for v in self.viewers]
data = self.session.data_collection
from glue.main import _loaded_plugins
return dict(session=context.id(self.session), viewers=viewers,
data=context.id(data), plugins=_loaded_plugins)
state = super().__gluestate__(context)
state['viewers'] = [context.id(v) for v in self.viewers]
return state

@classmethod
def __setgluestate__(cls, rec, context):
self = cls(data_collection=context.object(rec['data']))
# manually register the newly-created session, which the viewers need
context.register_object(rec['session'], self.session)
self = super().__setgluestate__(rec, context)
for v in rec['viewers']:
viewer = context.object(v)
self._viewer_refs.append(weakref.ref(viewer))
Expand Down

0 comments on commit b7e5392

Please sign in to comment.