comparison rhodecode/model/__init__.py @ 2165:dc2584ba5fbc

merged beta into default branch
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 28 Mar 2012 19:54:16 +0200
parents 82a88013a3fd 50aa7cb78cfe
children 63e58ef80ef1
comparison
equal deleted inserted replaced
2097:8fd6650bb436 2165:dc2584ba5fbc
83 :param callback: callback to call if all lookups failed 83 :param callback: callback to call if all lookups failed
84 """ 84 """
85 85
86 if isinstance(instance, cls): 86 if isinstance(instance, cls):
87 return instance 87 return instance
88 elif isinstance(instance, int) or str(instance).isdigit(): 88 elif isinstance(instance, (int, long)) or str(instance).isdigit():
89 return cls.get(instance) 89 return cls.get(instance)
90 else: 90 else:
91 if instance: 91 if instance:
92 if callback is None: 92 if callback is None:
93 raise Exception( 93 raise Exception(
94 'given object must be int or Instance of %s got %s, ' 94 'given object must be int, long or Instance of %s '
95 'no callback provided' % (cls, type(instance)) 95 'got %s, no callback provided' % (cls, type(instance))
96 ) 96 )
97 else: 97 else:
98 return callback(instance) 98 return callback(instance)