On Wed, 18 Nov 2009, Gregory Favre wrote:
> from invenio.search_engine import search_pattern, print_record
> from invenio.bibformat import format_record
>
> import invenio.template
> websearch_templates = invenio.template.load('websearch')
>
> out = []
> results = search_pattern(p='My pattern', f='field restriction')
> out.append(websearch_templates.tmpl_xml_marc_prologue())
> for recid in results:
>     out.append(print_record(recid, 'xm'))
>
> out.append(websearch_templates.tmpl_xml_marc_epilogue())
> marc_xml = ''.join(out)

While this is good, it is of course not optimal to call several
lower-level APIs instead of one higher-level API function.  I have now
fixed perform_request_search() (and print_records()) so that you could
use them directly with XML and Text MARC formats, like in the following
example:

  >>> import cStringIO
  >>> tmp = cStringIO.StringIO()
  >>> perform_request_search(req=tmp, p='ellis', of='xm')
  >>> out = tmp.getvalue()
  >>> tmp.close()
  >>> # `out' now contains MARCXML of 12 records found

You would need to patch v0.99.1 in a few places, following what was
needed for git/master:
<http://cdsware.cern.ch/repo/?p=cds-invenio.git;a=commitdiff;h=12841e725662d1cd91b5cc85224bc5fbc082c752;hp=f63a464248ef67901ea5df8f3e7acfd68e20d324>

Best regards
-- 
Tibor Simko ** CERN Document Server ** <http://cds.cern.ch/>

Reply via email to