Changeset - 169807710db2
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-07-27 01:01:02
marcin@python-works.com
fixed possible unicode errors on repo get function
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/__init__.py
Show inline comments
 
@@ -40,12 +40,13 @@
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import logging
 
from rhodecode.model import meta
 
from rhodecode.lib.utils2 import safe_str
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def init_model(engine):
 
    """
 
@@ -83,13 +84,13 @@ class BaseModel(object):
 
        :param instance: int or Instance
 
        :param callback: callback to call if all lookups failed
 
        """
 

	
 
        if isinstance(instance, cls):
 
            return instance
 
        elif isinstance(instance, (int, long)) or str(instance).isdigit():
 
        elif isinstance(instance, (int, long)) or safe_str(instance).isdigit():
 
            return cls.get(instance)
 
        else:
 
            if instance:
 
                if callback is None:
 
                    raise Exception(
 
                        'given object must be int, long or Instance of %s '
rhodecode/model/scm.py
Show inline comments
 
@@ -183,13 +183,13 @@ class ScmModel(BaseModel):
 
    """
 

	
 
    def __get_repo(self, instance):
 
        cls = Repository
 
        if isinstance(instance, cls):
 
            return instance
 
        elif isinstance(instance, int) or str(instance).isdigit():
 
        elif isinstance(instance, int) or safe_str(instance).isdigit():
 
            return cls.get(instance)
 
        elif isinstance(instance, basestring):
 
            return cls.get_by_repo_name(instance)
 
        elif instance:
 
            raise Exception('given object must be int, basestr or Instance'
 
                            ' of %s got %s' % (type(cls), type(instance)))
 
@@ -589,7 +589,7 @@ class ScmModel(BaseModel):
 
            log.debug('writing hook file !')
 
            with open(_hook_file, 'wb') as f:
 
                tmpl = tmpl.replace('_TMPL_', rhodecode.__version__)
 
                f.write(tmpl)
 
            os.chmod(_hook_file, 0755)
 
        else:
 
            log.debug('skipping writing hook file')
 
\ No newline at end of file
 
            log.debug('skipping writing hook file')
0 comments (0 inline, 0 general)