<s> """<STR_LIT>""" <EOL> from django . http import Http404 <EOL> from django . utils . translation import ugettext as _ <EOL> from django . views . generic . list_detail import object_list <EOL> from tagging . models import Tag , TaggedItem <EOL> from tagging . utils import get_tag , get_queryset_and_model <EOL> def tagged_object_list ( request , queryset_or_model = None , tag = None , <EOL> related_tags = False , related_tag_counts = True , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if queryset_or_model is None : <EOL> try : <EOL> queryset_or_model = kwargs . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> raise AttributeError ( _ ( '<STR_LIT>' ) ) <EOL> if tag is None : <EOL> try : <EOL> tag = kwargs . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> raise AttributeError ( _ ( '<STR_LIT>' ) ) <EOL> tag_instance = get_tag ( tag ) <EOL> if tag_instance is None : <EOL> raise Http404 ( _ ( '<STR_LIT>' ) % tag ) <EOL> queryset = TaggedItem . objects . get_by_model ( queryset_or_model , tag_instance ) <EOL> if not kwargs . has_key ( '<STR_LIT>' ) : <EOL> kwargs [ '<STR_LIT>' ] = { } <EOL> kwargs [ '<STR_LIT>' ] [ '<STR_LIT>' ] = tag_instance <EOL> if related_tags : <EOL> kwargs [ '<STR_LIT>' ] [ '<STR_LIT>' ] = Tag . objects . related_for_model ( tag_instance , queryset_or_model , <EOL> counts = related_tag_counts ) <EOL> return object_list ( request , queryset , ** kwargs ) </s>
