diff options
author | Marcin Kuzminski <marcin@python-works.com> | 2012-01-28 01:06:29 +0200 |
---|---|---|
committer | Marcin Kuzminski <marcin@python-works.com> | 2012-01-28 01:06:29 +0200 |
commit | d4e540f70af3cf79b8a13cbcdb6a74b6c6d75af9 (patch) | |
tree | d7d612464c0748a61654cfb0574de87c27808e27 /rhodecode/model/__init__.py | |
parent | c6b3ec29e04bc5494ffdcb58840fc532080d697f (diff) |
#227 Initial version of repository groups permissions system
- implemented none/read/write/admin permissions for groups
- wrote more tests for permissions, and new permissions groups
- a lot of code garden, splitted logic into proper models
- permissions on groups doesn't propagate yet to repositories
- deprecated some methods on api for managing permissions on
repositories for users, and users groups
--HG--
branch : beta
Diffstat (limited to 'rhodecode/model/__init__.py')
-rw-r--r-- | rhodecode/model/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/rhodecode/model/__init__.py b/rhodecode/model/__init__.py index 5c435a2b..b11325d2 100644 --- a/rhodecode/model/__init__.py +++ b/rhodecode/model/__init__.py @@ -74,12 +74,13 @@ class BaseModel(object): else: self.sa = meta.Session - def _get_instance(self, cls, instance): + def _get_instance(self, cls, instance, callback=None): """ - Get's instance of given cls using some simple lookup mechanism + Get's instance of given cls using some simple lookup mechanism. :param cls: class to fetch :param instance: int or Instance + :param callback: callback to call if all lookups failed """ if isinstance(instance, cls): @@ -88,5 +89,10 @@ class BaseModel(object): return cls.get(instance) else: if instance: - raise Exception('given object must be int or Instance' - ' of %s got %s' % (type(cls), type(instance))) + if callback is None: + raise Exception( + 'given object must be int or Instance of %s got %s, ' + 'no callback provided' % (cls, type(instance)) + ) + else: + return callback(instance) |