Make the "registered" attribute equal for all images when registering.
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 29 Aug 2004 17:20:05 +0000 (17:20 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 29 Aug 2004 17:20:05 +0000 (17:20 +0000)
Fixes ticket #41.

src/cmdline/kofoto
src/gkofoto/gkofoto/registerimagesdialog.py
src/lib/kofoto/shelf.py

index 3fa9461..48d1309 100755 (executable)
@@ -5,6 +5,7 @@ import locale
 import os
 from sets import Set
 import sys
+import time
 
 ######################################################################
 
@@ -464,10 +465,15 @@ def cmdRegister(env, args):
     if len(args) < 2:
         raise ArgumentError
     destalbum = env.shelf.getAlbum(args[0])
-    registerHelper(env, destalbum, [env.to_l(x) for x in args[1:]])
+    registrationTimeString = unicode(time.strftime("%Y-%m-%d %H:%M:%S"))
+    registerHelper(
+        env,
+        destalbum,
+        registrationTimeString,
+        [env.to_l(x) for x in args[1:]])
 
 
-def registerHelper(env, destalbum, paths):
+def registerHelper(env, destalbum, registrationTimeString, paths):
     paths.sort()
     newchildren = []
     for path in paths:
@@ -490,12 +496,15 @@ def registerHelper(env, destalbum, paths):
             env.out("Registered directory %s as an album with tag %s\n" % (
                 path,
                 tag))
-            registerHelper(env,
-                           album,
-                           [os.path.join(path, x) for x in os.listdir(path)])
+            registerHelper(
+                env,
+                album,
+                registrationTimeString,
+                [os.path.join(path, x) for x in os.listdir(path)])
         elif os.path.isfile(path):
             try:
                 image = env.shelf.createImage(env.to_u(path))
+                image.setAttribute(u"registered", registrationTimeString)
                 newchildren.append(image)
                 if env.verbose:
                     env.out("Registered image: %s\n" % path)
index a86599c..1dd0e23 100644 (file)
@@ -1,5 +1,6 @@
 import gtk
 import os
+import time
 from environment import env
 from kofoto.shelf import ImageExistsError, NotAnImageError, makeValidTag
 from kofoto.clientutils import walk_files
@@ -33,6 +34,7 @@ class RegisterImagesDialog(gtk.FileSelection):
         nonImages = 0
         filesInvestigated = 0
         images = []
+        registrationTimeString = unicode(time.strftime("%Y-%m-%d %H:%M:%S"))
         for filepath in walk_files(self.get_selections()):
             try:
                 try:
@@ -40,6 +42,7 @@ class RegisterImagesDialog(gtk.FileSelection):
                 except UnicodeDecodeError:
                     filepath = filepath.decode("latin1")
                 image = env.shelf.createImage(filepath)
+                image.setAttribute(u"registered", registrationTimeString)
                 images.append(image)
                 newImages += 1
                 newImagesCount.set_text(str(newImages))
index 265dcea..62c12b0 100644 (file)
@@ -780,13 +780,6 @@ class Shelf:
                 " where objectid = %s",
                 imageid)
             raise ImageExistsError, path
-        now = unicode(time.strftime("%Y-%m-%d %H:%M:%S"))
-        cursor.execute(
-            " insert into attribute (objectid, name, value, lcvalue)"
-            " values (%s, 'registered', %s, %s)",
-            imageid,
-            now,
-            now)
         image = self._imageFactory(
             imageid, imghash, location, mtime, width, height)
         image = self.getImage(imageid)