<s> from urlparse import urlsplit , urlunsplit <EOL> from django . core . urlresolvers import reverse as _reverse <EOL> from django . shortcuts import _get_queryset , get_object_or_404 <EOL> from django . http import Http404 <EOL> from django . contrib . sites . models import Site <EOL> from sugar . views . exceptions import Ajax404 <EOL> def reverse ( view_name , * args , ** kwargs ) : <EOL> return _reverse ( view_name , args = args , kwargs = kwargs ) <EOL> def absolutize_uri ( request , local_url ) : <EOL> request_url = urlsplit ( request . build_absolute_uri ( local_url ) ) <EOL> absolute_url = urlunsplit ( request_url [ : <NUM_LIT:1> ] + ( Site . objects . get_current ( ) . domain , ) + request_url [ <NUM_LIT:2> : ] ) <EOL> return absolute_url <EOL> def get_object_or_404_ajax ( * args , ** kwargs ) : <EOL> try : <EOL> return get_object_or_404 ( * args , ** kwargs ) <EOL> except Http404 , e : <EOL> raise Ajax404 , e <EOL> def get_object_or_none ( klass , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> queryset = _get_queryset ( klass ) <EOL> try : <EOL> return queryset . get ( * args , ** kwargs ) <EOL> except queryset . model . DoesNotExist : <EOL> return None </s>
