Mercurial > kallithea
comparison rhodecode/model/__init__.py @ 2672:169807710db2 beta
fixed possible unicode errors on repo get function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 27 Jul 2012 01:01:02 +0200 |
parents | e4d2271e1193 |
children | 63e58ef80ef1 12fce5e499d5 |
comparison
equal
deleted
inserted
replaced
2671:8990d58fb22f | 2672:169807710db2 |
---|---|
41 # You should have received a copy of the GNU General Public License | 41 # You should have received a copy of the GNU General Public License |
42 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 42 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
43 | 43 |
44 import logging | 44 import logging |
45 from rhodecode.model import meta | 45 from rhodecode.model import meta |
46 from rhodecode.lib.utils2 import safe_str | |
46 | 47 |
47 log = logging.getLogger(__name__) | 48 log = logging.getLogger(__name__) |
48 | 49 |
49 | 50 |
50 def init_model(engine): | 51 def init_model(engine): |
84 :param callback: callback to call if all lookups failed | 85 :param callback: callback to call if all lookups failed |
85 """ | 86 """ |
86 | 87 |
87 if isinstance(instance, cls): | 88 if isinstance(instance, cls): |
88 return instance | 89 return instance |
89 elif isinstance(instance, (int, long)) or str(instance).isdigit(): | 90 elif isinstance(instance, (int, long)) or safe_str(instance).isdigit(): |
90 return cls.get(instance) | 91 return cls.get(instance) |
91 else: | 92 else: |
92 if instance: | 93 if instance: |
93 if callback is None: | 94 if callback is None: |
94 raise Exception( | 95 raise Exception( |