allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [1/5] git commit: [#7628] ticket:646 Fix trove update to handle duplicates
Date Wed, 03 Sep 2014 14:00:11 GMT
Repository: allura
Updated Branches:
  refs/heads/je/42cc_7628 [created] e15c41576


[#7628] ticket:646 Fix trove update to handle duplicates

It helps find each one of them.


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/862c7255
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/862c7255
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/862c7255

Branch: refs/heads/je/42cc_7628
Commit: 862c725565937bb188cd31d09e00a998ae74a45a
Parents: e790049
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Sep 3 13:11:42 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Sep 3 13:11:42 2014 +0300

----------------------------------------------------------------------
 Allura/allura/command/create_trove_categories.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/862c7255/Allura/allura/command/create_trove_categories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/create_trove_categories.py b/Allura/allura/command/create_trove_categories.py
index e520214..0501f49 100644
--- a/Allura/allura/command/create_trove_categories.py
+++ b/Allura/allura/command/create_trove_categories.py
@@ -38,7 +38,7 @@ class CreateTroveCategoriesCommand(base.Command):
 
     # NOTE: order is important
     # To add new migration append it's name to following list,
-    # and cretate method m__<migration_name>
+    # and create method m__<migration_name>
     migrations = [
         'add_agpl_and_lppl',
         'sync',
@@ -58,12 +58,13 @@ class CreateTroveCategoriesCommand(base.Command):
         M.TroveCategory(**data)
 
     def update_trove_cat(self, trove_cat_id, attr_dict):
-        t = M.TroveCategory.query.get(trove_cat_id=trove_cat_id)
-        if not t:
+        ts = M.TroveCategory.query.find(dict(trove_cat_id=trove_cat_id))
+        if ts.count() < 1:
             sys.exit("Couldn't find TroveCategory with trove_cat_id=%s" %
                      trove_cat_id)
-        for k, v in attr_dict.iteritems():
-            setattr(t, k, v)
+        for t in ts:
+            for k, v in attr_dict.iteritems():
+                setattr(t, k, v)
 
     # patching to avoid a *lot* of event hooks firing, and taking a long long time
     @patch.object(M.project.TroveCategoryMapperExtension, 'after_insert', Mock())


Mime
View raw message