form: remove unused ValidUrlWidget and UrlOrAbsPathWidget widgets (#6225)

This commit is contained in:
Frédéric Péters 2015-01-01 20:19:26 +01:00
parent 5c2401012b
commit 813a66a2c8
1 changed files with 0 additions and 49 deletions

View File

@ -986,55 +986,6 @@ class UrlWidget(ValidatedStringWidget):
if self.error:
self.error = _('must start with http:// or https:// and have a domain name')
class ValidUrlWidget(UrlWidget):
'''StringWidget which checks the value entered is a correct url for an existing page'''
def _parse(self, request):
UrlWidget._parse(self, request)
# Default value that indicates the proxy (if configured) is not disabled for this host yet
self.use_proxy = True
if self.value and not self.error:
status = 0
try:
response, status, page, auth_header = misc.http_get_page(self.value)
except Exception, msg:
# If the proxy is configured and the connection failed, try without the proxy
if not get_cfg('proxy', {}).get('enabled'):
self.error = msg
else:
try:
response, status, page, auth_header = misc.http_get_page(self.value, use_proxy=False)
except Exception, msg:
self.error = msg
return
else:
# Mark in the field that this host shouldn't use the proxy
self.use_proxy = False
if status == 401:
return
elif status == 403:
self.error = _('client error: access forbidden (error 403)')
elif status == 404:
self.error = _('client error: page not found (error 404)')
elif str(status)[0] == '4':
self.error = _('client error: %(reason)s (error %(code)s)') % {
'reason': status_reasons.get(status), 'code': status}
elif str(status)[0] == '5':
self.error = _('server error: %(reason)s (error %(code)s)') % {
'reason': status_reasons.get(status), 'code': status}
class UrlOrAbsPathWidget(UrlWidget):
'''StringWidget which checks the value entered is a correct url for an existing page'''
regex = r'^https?://.+'
def _parse(self, request):
UrlWidget._parse(self, request)
if self.error:
self.error = None
self.regex = '^/.*'
UrlWidget._parse(self, request)
if self.error:
self.error = _('must start with http:// or https:// and have a domain name or start with /')
class VarnameWidget(ValidatedStringWidget):
'''StringWidget which checks the value entered is a syntactically correct