diff options
Diffstat (limited to 'model.py')
-rw-r--r-- | model.py | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -28,7 +28,7 @@ class Model(gobject.GObject): ''' __gsignals__ = { 'add_link': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([int])) + gobject.TYPE_NONE, ([int])), } def __init__(self): @@ -44,13 +44,11 @@ class Model(gobject.GObject): index = self.data['shared_links'].index(item) break - self.data['shared_links'].insert(index, - {'hash':sha.new(str(url)).hexdigest(), - 'url':str(url), 'title':str(title), - 'thumb':base64.b64encode(thumb), - 'owner':str(owner), - 'color':str(color), - 'timestamp':float(timestamp)}) + info = {'hash': sha.new(str(url)).hexdigest(), 'url': str(url), + 'title': str(title), 'thumb': base64.b64encode(thumb), + 'owner': str(owner), 'color': str(color), + 'timestamp': float(timestamp)} + self.data['shared_links'].insert(index, info) self.emit('add_link', index) def remove_link(self, hash): @@ -65,10 +63,8 @@ class Model(gobject.GObject): def deserialize(self, data): self.data = cjson.decode(data) - if not self.data.has_key('shared_links'): - self.data['shared_links'] = [] - if not self.data.has_key('deleted'): - self.data['deleted'] = [] + self.data.setdefault('shared_links', []) + self.data.setdefault('deleted', []) def get_links_ids(self): ids = [] |