-from django.core.urlresolvers import reverse
-from django.db.models.query import QuerySet
-from piston.emitters import Emitter, XMLEmitter, JSONEmitter
-from catalogue.models import Book, Fragment, Tag
-from django.utils.translation import get_language
-
-
-class SsiQS(object):
- """A wrapper for QuerySet that won't serialize."""
-
- def __init__(self, queryset):
- self.queryset = queryset
-
- def __unicode__(self):
- raise TypeError("This is not serializable.")
-
- def get_ssis(self, emitter_format):
- """Yields SSI include statements for the queryset."""
- url_pattern = reverse('api_include',
- kwargs={'model': self.queryset.model.__name__.lower(),
- 'pk': '0000',
- 'emitter_format': emitter_format,
- 'lang': get_language(),
- })
- for instance in self.queryset:
- yield "<!--#include file='%s'-->" % url_pattern.replace('0000',
- str(instance.pk))