#NEWLINE# def canonical( model ) : #NEWLINE# #INDENT# '\n    Enforce a canonical URL for a resource.\n    ' #NEWLINE# def outer( view ) : #NEWLINE# #INDENT# def inner( request , id , slug = '' ) : #NEWLINE# #INDENT# instance = get_object_or_404 ( model , pk = id ) #NEWLINE# if ( not ( request . path == instance . get_absolute_url ( ) ) ) : #NEWLINE# #INDENT# return redirect ( instance , permanent = True ) #NEWLINE# #UNINDENT# return view ( request , instance ) #NEWLINE# #UNINDENT# return inner #NEWLINE# #UNINDENT# return outer