allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [10/12] git commit: [#6526] Set c.project before calling MountPointValidator
Date Wed, 28 Aug 2013 17:24:34 GMT
[#6526] Set c.project before calling MountPointValidator

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@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/6541
Commit: eceab844fdd664eff62b1a64380bce01a0767d07
Parents: 9704ca5
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Aug 28 16:08:34 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@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()


Mime
View raw message