You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/01/02 21:55:24 UTC

[3/3] git commit: [#4091] ticket:489 Remove per project database_uri and fix EnsureIndexCommand

[#4091] ticket:489 Remove per project database_uri and fix EnsureIndexCommand


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

Branch: refs/heads/master
Commit: ef0d3ea62cbe3d6aee773aa81e88aefaf37161f0
Parents: ef0562c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Dec 26 12:50:13 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Jan 2 20:55:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/command/show_models.py  | 23 +++++------------------
 Allura/allura/lib/plugin.py           |  4 ----
 Allura/allura/model/project.py        |  4 ++--
 Allura/allura/tests/test_app.py       |  1 -
 Allura/allura/tests/unit/factories.py |  1 -
 5 files changed, 7 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef0d3ea6/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index d24120d..f4d2784 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -228,24 +228,11 @@ class EnsureIndexCommand(base.Command):
             db = odm_session.impl.db
             for name, indexes in db_indexes.iteritems():
                 self._update_indexes(db[name], indexes)
-        base.log.info('Updating indexes for project DBs')
-        configured_dbs = set()
-        for projects in utils.chunked_find(M.Project):
-            for p in projects:
-                db = p.database_uri
-                if db in configured_dbs: continue
-                configured_dbs.add(db)
-                c.project = p
-                db = M.project_doc_session.db
-                base.log.info('... DB: %s', db)
-                for name, indexes in project_indexes.iteritems():
-                    self._update_indexes(db[name], indexes)
-        if not configured_dbs:
-            # e.g. during bootstrap with no projects
-            db = M.project_doc_session.db
-            base.log.info('... default DB: %s', db)
-            for name, indexes in project_indexes.iteritems():
-                self._update_indexes(db[name], indexes)
+        base.log.info('Updating indexes for project DB')
+        db = M.project_doc_session.db
+        base.log.info('... DB: %s', db)
+        for name, indexes in project_indexes.iteritems():
+            self._update_indexes(db[name], indexes)
         base.log.info('Done updating indexes')
 
     def _update_indexes(self, collection, indexes):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef0d3ea6/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 0c6c3b1..406ede9 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -431,14 +431,12 @@ class ProjectRegistrationProvider(object):
         from allura import model as M
         shortname = '--init--'
         name = 'Home Project for %s' % neighborhood.name
-        database_uri = M.Project.default_database_uri(shortname)
         p = M.Project(neighborhood_id=neighborhood._id,
                     shortname=shortname,
                     name=name,
                     short_description='',
                     description=('You can edit this description in the admin page'),
                     homepage_title = '# ' + name,
-                    database_uri=database_uri,
                     last_updated = datetime.utcnow(),
                     is_nbhd_project=True,
                     is_root=True)
@@ -514,7 +512,6 @@ class ProjectRegistrationProvider(object):
                     short_description='',
                     description=('You can edit this description in the admin page'),
                     homepage_title=shortname,
-                    database_uri=M.Project.default_database_uri(shortname),
                     last_updated = datetime.utcnow(),
                     is_nbhd_project=False,
                     is_root=True)
@@ -620,7 +617,6 @@ class ProjectRegistrationProvider(object):
             neighborhood_id=project.neighborhood_id,
             shortname=shortname,
             name=project_name or name,
-            database_uri=project.database_uri,
             last_updated = datetime.utcnow(),
             is_root=False,
             ordinal=ordinal,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef0d3ea6/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index b720343..1e5ff19 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -188,7 +188,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
     export_controlled=FieldProperty(bool, if_missing=False)
     export_control_type=FieldProperty(str, if_missing=None)
     database=FieldProperty(S.Deprecated)
-    database_uri=FieldProperty(str)
+    database_uri=FieldProperty(S.Deprecated)
     is_root=FieldProperty(bool)
     acl = FieldProperty(ACL(permissions=_perms_init))
     neighborhood_invitations=FieldProperty([S.ObjectId])
@@ -233,7 +233,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         return self.parent_project
 
     @classmethod
-    def default_database_uri(cls, shortname):
+    def database_uri(cls):
         return config.get('ming.project.uri')
 
     @LazyProperty

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef0d3ea6/Allura/allura/tests/test_app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_app.py b/Allura/allura/tests/test_app.py
index eea3abe..30c85c0 100644
--- a/Allura/allura/tests/test_app.py
+++ b/Allura/allura/tests/test_app.py
@@ -34,7 +34,6 @@ def setUp():
     c.project.name = 'Test Project'
     c.project.shortname = 'tp'
     c.project._id = 'testproject/'
-    c.project.database_uri = 'mim://nosetest:project'
     c.project.url = lambda: '/testproject/'
     app_config = mock.Mock()
     app_config._id = None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef0d3ea6/Allura/allura/tests/unit/factories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/factories.py b/Allura/allura/tests/unit/factories.py
index 50f24dd..20c33d1 100644
--- a/Allura/allura/tests/unit/factories.py
+++ b/Allura/allura/tests/unit/factories.py
@@ -37,7 +37,6 @@ def flush_on_return(fn):
 def create_project(shortname):
     neighborhood = create_neighborhood()
     return Project(shortname=shortname,
-                   database_uri='mim://test/myproject_db',
                    neighborhood_id=neighborhood._id,
                    is_root=True)