X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/d19e216035b14d8f60b24dda0c0670e6997f16ce..b4cd9f878117f7398442acb09d40b520f321a91d:/philo/contrib/sobol/models.py?ds=sidebyside diff --git a/philo/contrib/sobol/models.py b/philo/contrib/sobol/models.py index ee8187d..dbf37ef 100644 --- a/philo/contrib/sobol/models.py +++ b/philo/contrib/sobol/models.py @@ -1,22 +1,28 @@ +import datetime + +from django.conf import settings from django.conf.urls.defaults import patterns, url from django.contrib import messages from django.core.exceptions import ValidationError +from django.core.validators import URLValidator from django.db import models from django.http import HttpResponseRedirect, Http404, HttpResponse from django.utils import simplejson as json from django.utils.datastructures import SortedDict + from philo.contrib.sobol import registry from philo.contrib.sobol.forms import SearchForm from philo.contrib.sobol.utils import HASH_REDIRECT_GET_KEY, URL_REDIRECT_GET_KEY, SEARCH_ARG_GET_KEY, check_redirect_hash from philo.exceptions import ViewCanNotProvideSubpath from philo.models import MultiView, Page from philo.models.fields import SlugMultipleChoiceField -from philo.validators import RedirectValidator -import datetime -try: - import eventlet -except: - eventlet = False + +eventlet = None +if getattr(settings, 'SOBOL_USE_EVENTLET', False): + try: + import eventlet + except: + pass class Search(models.Model): @@ -77,7 +83,7 @@ class Search(models.Model): class ResultURL(models.Model): search = models.ForeignKey(Search, related_name='result_urls') - url = models.TextField(validators=[RedirectValidator()]) + url = models.TextField(validators=[URLValidator()]) def __unicode__(self): return self.url