Updated session.flush() to session.commit() for Elixir 0.6 (fixes #dec30)
authorDmitriy Morozov <dmitriy@mrzv.org>
Mon, 15 Sep 2008 15:05:47 -0700
changeset 16 eccbe49587f2
parent 15 73c27c2afa65
child 17 eeafcec1814f
Updated session.flush() to session.commit() for Elixir 0.6 (fixes #dec30)
.issues/dec30eef7890a112/new/1220656968.M805573P3863Q1.cole
.issues/dec30eef7890a112/new/1221516287.M441869P9259Q2.cole
alexandria.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/dec30eef7890a112/new/1220656968.M805573P3863Q1.cole	Mon Sep 15 15:05:47 2008 -0700
@@ -0,0 +1,8 @@
+From: Dmitriy Morozov <dmitriy@mrzv.org>
+Date: Fri, 05 Sep 2008 16:22:09
+State: resolved
+Subject: Cannot remove or correctly update a paper
+Message-Id: <dec30eef7890a112-0-artemis@cole>
+resolution: fixed
+
+In my library I can neither update the title, nor remove the paper 46b.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/dec30eef7890a112/new/1221516287.M441869P9259Q2.cole	Mon Sep 15 15:05:47 2008 -0700
@@ -0,0 +1,9 @@
+From: Dmitriy Morozov <dmitriy@mrzv.org>
+Date: Mon, 15 Sep 2008 15:04:47
+Subject: properties changes (state, resolution)
+Message-Id: <dec30eef7890a112-bfc7701a34fdd683-artemis@cole>
+References: <dec30eef7890a112-0-artemis@cole>
+In-Reply-To: <dec30eef7890a112-0-artemis@cole>
+
+state=resolved
+resolution=fixed
--- a/alexandria.py	Fri Sep 05 15:57:47 2008 -0700
+++ b/alexandria.py	Mon Sep 15 15:05:47 2008 -0700
@@ -54,7 +54,7 @@
     p = Paper(path = path, md5 = m.hexdigest())
     _set_options(p, options, required = ['title'])
 
-    session.flush()
+    session.commit()
     _show_paper(p)
 
 def update(args, options):
@@ -62,14 +62,16 @@
     p = Paper.query.filter(Paper.md5.startswith(args[0])).one()
     if len(args) > 1: p.path = _short_path(args[1], options)
     _set_options(p, options)
-    session.flush()
+    session.commit()
     _show_paper(p)
 
 def view(args, options):
     """view paper by hash"""
     if len(args) < 1: return
     p = Paper.query.filter(Paper.md5.startswith(args[0])).all()
-    if not p: return
+    if not p: 
+        print _colorize_string('error', 'No such paper')
+        return
     if len(p) > 1:
         print _colorize_string('error', 'Too many choices')
         return
@@ -87,11 +89,11 @@
     print "Removing"
     _show_paper(p)
     p.delete()
-    session.flush()
+    session.commit()
 
 def list(args, options):
     """list papers in the database"""
-    papers = Paper.query
+    papers = Paper.query.order_by(asc(Paper.title))
 
     # Refactor with _set_options()
     for label_with_commas in (options.labels or []):
@@ -149,12 +151,12 @@
             an = AuthorNickname.get_by(name = unicode(args[0][1:]))
             if an:
                 an.delete()
-                session.flush()
+                session.commit()
         else:
             a =  Author.get_by_or_init(name = unicode(args[0]))
             an = AuthorNickname.get_by_or_init(name = unicode(args[1]))
             an.author = a
-            session.flush()
+            session.commit()
 
     _show_authors(options)
 
@@ -170,7 +172,7 @@
                 t2.papers.append(p)
                 t.papers.remove(p)
             t.delete()
-    session.flush()
+    session.commit()
 
     print "Labels:"
     for t in Tag.query.order_by(asc(Tag.name)).all():
@@ -178,7 +180,7 @@
             t.delete()
             continue
         print '  (%d) %s' % (len(t.papers), t.name)
-    session.flush()
+    session.commit()
 
 def info(args, options):
     """Show information about a path"""