Mercurial > libervia-backend
diff frontends/src/quick_frontend/quick_blog.py @ 1761:ad20cedbf25e
quick_frontend (blog): replaced first argument in addEntry by edit_entry, so it can be managed separately from entries + handle it in Entry.delete
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 18 Dec 2015 19:36:00 +0100 |
parents | bf67dc424784 |
children | d17772b0fe22 |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_blog.py Fri Dec 18 15:06:58 2015 +0100 +++ b/frontends/src/quick_frontend/quick_blog.py Fri Dec 18 19:36:00 2015 +0100 @@ -103,7 +103,7 @@ else: self.blog = manager.blog self.entries = [] - self._first_entry = None + self.edit_entry = None @property def level(self): @@ -140,7 +140,7 @@ for item, comments in items: self.addEntry(item, comments, service=service, node=node, with_update=False) - def addEntry(self, item=None, comments=None, service=None, node=None, with_update=True, editable=False, first=False): + def addEntry(self, item=None, comments=None, service=None, node=None, with_update=True, editable=False, edit_entry=False): """Add a microblog entry @param editable (bool): True if the entry can be modified @@ -149,12 +149,14 @@ @param service (jid.JID, None): service where the entry is coming from @param service (unicode, None): node hosting the entry @param with_update (bool): if True, udpate is called with the new entry - @param first(bool): if True, will be the first entry regardless of sorting + @param edit_entry(bool): if True, will be in self.edit_entry instead of + self.entries, so it can be managed separately (e.g. first or last + entry regardless of sorting) """ new_entry = ENTRY_CLS(self, item, comments, service=service, node=node) new_entry.setEditable(editable) - if first: - self._first_entry = new_entry + if edit_entry: + self.edit_entry = new_entry else: self.entries.append(new_entry) if with_update: @@ -289,7 +291,13 @@ log.debug(u"deleting entry {}".format('EDIT ENTRY' if self.new else self.item.id)) for child in self.entries: child.delete() - self.manager.entries.remove(self) + try: + self.manager.entries.remove(self) + except ValueError: + if self != self.manager.edit_entry: + log.error(u"Internal Error: entry not found in manager") + else: + self.manager.edit_entry = None if not self.new: # we must remove references to self # in QuickBlog's dictionary