def handle(self, bibid, **options): record = voyager.get_marc_blob(bibid) if options['format'] == 'json': print record.as_json(indent=2) elif options['format'] == 'xml': print record_to_xml(record) else: print record.as_marc21()
def records(): cursor = connection.cursor() query = """ SELECT BIB_ID FROM bib_master WHERE SUPPRESS_IN_OPAC = 'N' ORDER BY BIB_ID DESC """ cursor.execute(query) while True: try: row = cursor.fetchone() if not row: break bib_id = row[0] record = get_marc_blob(bib_id) yield bib_id, record except Exception as e: logging.warn("exception when getting marc for %s: %s", bib_id, e)
def item_marc(request, bibid): rec = voyager.get_marc_blob(bibid) if not rec: return HttpResponse('{}', content_type='application/json', status=404) return HttpResponse(rec.as_json(indent=2), content_type='application/json')