Mercurial > kallithea
comparison rhodecode/model/forms.py @ 1261:30828b1ebe20 beta
added dump validation of cloneurl, it can still freeze if server will ask for auth.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 16 Apr 2011 21:05:21 +0200 |
parents | 6832ef664673 |
children | aa7e45ad0cea |
comparison
equal
deleted
inserted
replaced
1260:83da8834f7b1 | 1261:30828b1ebe20 |
---|---|
224 return slug | 224 return slug |
225 | 225 |
226 | 226 |
227 return _ValidRepoName | 227 return _ValidRepoName |
228 | 228 |
229 def ValidCloneUri(): | |
230 from mercurial.httprepo import httprepository, httpsrepository | |
231 from rhodecode.lib.utils import make_ui | |
232 | |
233 class _ValidCloneUri(formencode.validators.FancyValidator): | |
234 def to_python(self, value, state): | |
235 if not value: | |
236 pass | |
237 elif value.startswith('https'): | |
238 try: | |
239 httpsrepository(make_ui('db'), value).capabilities() | |
240 except: | |
241 raise formencode.Invalid(_('invalid clone url'), value, | |
242 state) | |
243 elif value.startswith('http'): | |
244 try: | |
245 httprepository(make_ui('db'), value).capabilities() | |
246 except: | |
247 raise formencode.Invalid(_('invalid clone url'), value, | |
248 state) | |
249 else: | |
250 raise formencode.Invalid(_('Invalid clone url, provide a ' | |
251 'valid clone http\s url'), value, | |
252 state) | |
253 | |
254 return _ValidCloneUri | |
255 | |
229 def ValidForkType(old_data): | 256 def ValidForkType(old_data): |
230 class _ValidForkType(formencode.validators.FancyValidator): | 257 class _ValidForkType(formencode.validators.FancyValidator): |
231 | 258 |
232 def to_python(self, value, state): | 259 def to_python(self, value, state): |
233 if old_data['repo_type'] != value: | 260 if old_data['repo_type'] != value: |
234 raise formencode.Invalid(_('Fork have to be the same type as original'), | 261 raise formencode.Invalid(_('Fork have to be the same ' |
235 value, state) | 262 'type as original'), value, state) |
236 return value | 263 return value |
237 return _ValidForkType | 264 return _ValidForkType |
238 | 265 |
239 class ValidPerms(formencode.validators.FancyValidator): | 266 class ValidPerms(formencode.validators.FancyValidator): |
240 messages = {'perm_new_member_name':_('This username or users group name' | 267 messages = {'perm_new_member_name':_('This username or users group name' |
455 class _RepoForm(formencode.Schema): | 482 class _RepoForm(formencode.Schema): |
456 allow_extra_fields = True | 483 allow_extra_fields = True |
457 filter_extra_fields = False | 484 filter_extra_fields = False |
458 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), | 485 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
459 ValidRepoName(edit, old_data)) | 486 ValidRepoName(edit, old_data)) |
460 clone_uri = UnicodeString(strip=True, min=1, not_empty=False) | 487 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False), |
488 ValidCloneUri()()) | |
461 repo_group = OneOf(repo_groups, hideList=True) | 489 repo_group = OneOf(repo_groups, hideList=True) |
462 repo_type = OneOf(supported_backends) | 490 repo_type = OneOf(supported_backends) |
463 description = UnicodeString(strip=True, min=1, not_empty=True) | 491 description = UnicodeString(strip=True, min=1, not_empty=True) |
464 private = StringBoolean(if_missing=False) | 492 private = StringBoolean(if_missing=False) |
465 enable_statistics = StringBoolean(if_missing=False) | 493 enable_statistics = StringBoolean(if_missing=False) |