예제 #1
0
파일: views.py 프로젝트: kznmft/regluit
    def get(self, request, *args, **kwargs):
        work = request.GET.get('work', None)

        if work:
            try:
                work = models.safe_get_work(work)
            except models.Work.DoesNotExist:
                raise Http404
            return HttpResponse(onix.onix_feed_for_work(work),
                                content_type="text/xml")

        facet = kwargs.get('facet', 'all')

        if not facet:
            return HttpResponseBadRequest(content='No facet provided')

        max_records = request.GET.get('max', 100)

        try:
            max_records = int(max_records)
        except Exception:
            max_records = None

        facet_class = opds.get_facet_class(facet)()
        page = request.GET.get('page', None)
        try:
            page = int(page)
        except:
            page = None

        feed = onix.onix_feed(facet_class, max_records, page_number=page)
        return StreamingHttpResponse(feed, content_type="text/xml")
예제 #2
0
 def get(self, request, *args, **kwargs):
     work = request.GET.get('work', None)
     if work:
         try:
             work = models.safe_get_work(work)
         except models.Work.DoesNotExist:
             raise Http404
         return HttpResponse(onix.onix_feed_for_work(work),
                             content_type="text/xml")
     facet = kwargs.get('facet', 'all')
     if facet:
         max = request.GET.get('max', 100)
         try:
             max = int(max)
         except:
             max = None
         facet_class = opds.get_facet_class(facet)()
         return HttpResponse(onix.onix_feed(facet_class, max),
                             content_type="text/xml")
예제 #3
0
파일: push.py 프로젝트: kznmft/regluit
def push_onix(target, facet_class):
    target.push_file(
        'unglueit_onix_{:%Y%m%d%H%M%S}.xml'.format(datetime.now()),
        StringIO(onix_feed(facet_class))
    )