<s> """<STR_LIT>""" <EOL> import urllib <EOL> import textwrap <EOL> from django . core import urlresolvers <EOL> from django . http import HttpResponseRedirect <EOL> from django . shortcuts import render_to_response <EOL> from django . template import RequestContext <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from django . contrib import comments <EOL> from django . utils . http import is_safe_url <EOL> def next_redirect ( request , default , default_view , ** get_kwargs ) : <EOL> """<STR_LIT>""" <EOL> next = request . POST . get ( '<STR_LIT>' , default ) <EOL> if not is_safe_url ( url = next , host = request . get_host ( ) ) : <EOL> next = urlresolvers . reverse ( default_view ) <EOL> if get_kwargs : <EOL> if '<STR_LIT:#>' in next : <EOL> tmp = next . rsplit ( '<STR_LIT:#>' , <NUM_LIT:1> ) <EOL> next = tmp [ <NUM_LIT:0> ] <EOL> anchor = '<STR_LIT:#>' + tmp [ <NUM_LIT:1> ] <EOL> else : <EOL> anchor = '<STR_LIT>' <EOL> joiner = ( '<STR_LIT:?>' in next ) and '<STR_LIT:&>' or '<STR_LIT:?>' <EOL> next += joiner + urllib . urlencode ( get_kwargs ) + anchor <EOL> return HttpResponseRedirect ( next ) <EOL> def confirmation_view ( template , doc = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> def confirmed ( request ) : <EOL> comment = None <EOL> if '<STR_LIT:c>' in request . GET : <EOL> try : <EOL> comment = comments . get_model ( ) . objects . get ( pk = request . GET [ '<STR_LIT:c>' ] ) <EOL> except ( ObjectDoesNotExist , ValueError ) : <EOL> pass <EOL> return render_to_response ( template , <EOL> { '<STR_LIT>' : comment } , <EOL> context_instance = RequestContext ( request ) <EOL> ) <EOL> confirmed . __doc__ = textwrap . dedent ( """<STR_LIT>""" % ( doc , template ) <EOL> ) <EOL> return confirmed </s>
