Changeset - e3deb588cf14
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-05-01 22:21:19
marcin@python-works.com
fixed http/s validation for clone_uri, and missing return value.
1 file changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/forms.py
Show inline comments
 
@@ -22,6 +22,7 @@ for SELECT use formencode.All(OneOf(list
 
import os
 
import re
 
import logging
 
import traceback
 

	
 
import formencode
 
from formencode import All
 
@@ -227,25 +228,29 @@ def ValidCloneUri():
 
    from rhodecode.lib.utils import make_ui
 

	
 
    class _ValidCloneUri(formencode.validators.FancyValidator):
 

	
 
        def to_python(self, value, state):
 
            if not value:
 
                pass
 
            elif value.startswith('https'):
 
                try:
 
                    httpsrepository(make_ui('db'), value).capabilities()
 
                except:
 
                    httpsrepository(make_ui('db'), value).capabilities
 
                except Exception, e:
 
                    log.error(traceback.format_exc())
 
                    raise formencode.Invalid(_('invalid clone url'), value,
 
                                             state)
 
            elif value.startswith('http'):
 
                try:
 
                    httprepository(make_ui('db'), value).capabilities()
 
                except:
 
                    httprepository(make_ui('db'), value).capabilities
 
                except Exception, e:
 
                    log.error(traceback.format_exc())
 
                    raise formencode.Invalid(_('invalid clone url'), value,
 
                                             state)
 
            else:
 
                raise formencode.Invalid(_('Invalid clone url, provide a '
 
                                           'valid clone http\s url'), value,
 
                                         state)
 
            return value
 

	
 
    return _ValidCloneUri
 

	
0 comments (0 inline, 0 general)