def save_entry(self, entry):
slug = self._generate_slug(entry.title)
- self.db.execute("INSERT INTO planet(author_id, title, slug, markdown, published) "
+ id = self.db.execute("INSERT INTO planet(author_id, title, slug, markdown, published) "
"VALUES(%s, %s, %s, %s, UTC_TIMESTAMP())", entry.author.uid, entry.title,
slug, entry.markdown)
+ return id
+
def search(self, what):
# Split tags.
tags = what.split()
entry.set("markdown", self.get_argument("markdown"))
entry.set("author_id", self.current_user)
- tags = self.get_argument("tags", "")
- entry.tags = tags.split()
-
if id:
self.planet.update_entry(entry)
else:
- self.planet.save_entry(entry)
+ id = self.planet.save_entry(entry)
+ entry.id = id
+
+ tags = self.get_argument("tags", "")
+ entry.tags = tags.split()
self.redirect("/planet")