You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/09/05 20:20:37 UTC

[12/50] git commit: [#6526] Set c.project before calling MountPointValidator

[#6526] Set c.project before calling MountPointValidator

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/6596
Commit: eceab844fdd664eff62b1a64380bce01a0767d07
Parents: 9704ca5
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Aug 28 16:08:34 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Wed Aug 28 16:08:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/validators.py | 6 ++----
 Allura/allura/model/project.py  | 9 +++++----
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eceab844/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 9d15429..3295bb0 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -90,8 +90,7 @@ class MountPointValidator(fev.UnicodeString):
         if mount_point in self.reserved_mount_points:
             raise fe.Invalid('Mount point "%s" is reserved' % mount_point,
                     value, state)
-        if (getattr(c, 'project', None) and
-                c.project.app_instance(mount_point) is not None):
+        if c.project and c.project.app_instance(mount_point) is not None:
             raise fe.Invalid('Mount point "%s" is already in use' % mount_point,
                     value, state)
         return mount_point
@@ -100,8 +99,7 @@ class MountPointValidator(fev.UnicodeString):
         base_mount_point = mount_point = self.app_class.default_mount_point
         i = 0
         while True:
-            if (not getattr(c, 'project', None) or
-                    c.project.app_instance(mount_point) is None):
+            if not c.project or c.project.app_instance(mount_point) is None:
                 return mount_point
             mount_point = base_mount_point + '-%d' % i
             i += 1

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eceab844/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 983ef66..ec39157 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -600,10 +600,11 @@ class Project(MappedClass, ActivityNode, ActivityObject):
 
     def install_app(self, ep_name, mount_point=None, mount_label=None, ordinal=None, **override_options):
         App = g.entry_points['tool'][ep_name]
-        try:
-            mount_point = v.MountPointValidator(App).to_python(mount_point)
-        except fe.Invalid as e:
-            raise exceptions.ToolError(str(e))
+        with h.push_config(c, project=self):
+            try:
+                mount_point = v.MountPointValidator(App).to_python(mount_point)
+            except fe.Invalid as e:
+                raise exceptions.ToolError(str(e))
         if ordinal is None:
             ordinal = int(self.ordered_mounts(include_hidden=True)[-1]['ordinal']) + 1
         options = App.default_options()