Mercurial > kallithea
comparison rhodecode/model/__init__.py @ 1982:87f0800abc7b beta
#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
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 28 Jan 2012 01:06:29 +0200 |
parents | a76e9bacbedc |
children | 82a88013a3fd 50aa7cb78cfe |
comparison
equal
deleted
inserted
replaced
1981:518f87919375 | 1982:87f0800abc7b |
---|---|
72 if sa is not None: | 72 if sa is not None: |
73 self.sa = sa | 73 self.sa = sa |
74 else: | 74 else: |
75 self.sa = meta.Session | 75 self.sa = meta.Session |
76 | 76 |
77 def _get_instance(self, cls, instance): | 77 def _get_instance(self, cls, instance, callback=None): |
78 """ | 78 """ |
79 Get's instance of given cls using some simple lookup mechanism | 79 Get's instance of given cls using some simple lookup mechanism. |
80 | 80 |
81 :param cls: class to fetch | 81 :param cls: class to fetch |
82 :param instance: int or Instance | 82 :param instance: int or Instance |
83 :param callback: callback to call if all lookups failed | |
83 """ | 84 """ |
84 | 85 |
85 if isinstance(instance, cls): | 86 if isinstance(instance, cls): |
86 return instance | 87 return instance |
87 elif isinstance(instance, int) or str(instance).isdigit(): | 88 elif isinstance(instance, int) or str(instance).isdigit(): |
88 return cls.get(instance) | 89 return cls.get(instance) |
89 else: | 90 else: |
90 if instance: | 91 if instance: |
91 raise Exception('given object must be int or Instance' | 92 if callback is None: |
92 ' of %s got %s' % (type(cls), type(instance))) | 93 raise Exception( |
94 'given object must be int or Instance of %s got %s, ' | |
95 'no callback provided' % (cls, type(instance)) | |
96 ) | |
97 else: | |
98 return callback(instance) |