[open-ils-commits] r8266 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers lib/acq templates/oils/default/acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Dec 21 09:53:36 EST 2007
Author: erickson
Date: 2007-12-21 09:31:38 -0500 (Fri, 21 Dec 2007)
New Revision: 8266
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
Log:
now encoding flattened bib data is json. added extractor function to display non-json in search results
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py 2007-12-21 14:04:18 UTC (rev 8265)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py 2007-12-21 14:31:38 UTC (rev 8266)
@@ -5,7 +5,7 @@
import oilsweb.lib.context
import oilsweb.lib.util
import oilsweb.lib.acq.search
-import osrf.cache
+import osrf.cache, osrf.json
from oilsweb.lib.context import Context, SubContext, ContextItem
log = logging.getLogger(__name__)
@@ -49,6 +49,7 @@
if c.oils.acq.search_source:
c.oils_acq_records, c.oils.acq.search_cache_key = self._build_z39_search(c.oils)
+ c.oils.acq.extract_bib_field = oilsweb.lib.acq.search.extract_bib_field
return render('oils/%s/acq/pl_builder.html' % c.oils.core.skin)
@@ -78,18 +79,14 @@
c.oils = oilsweb.lib.context.Context.init(request)
rec_id = c.oils.acq.record_id
cache_key = c.oils.acq.search_cache_key
- logging.info("record = " + str(rec_id))
- logging.info("cache_key = " + str(cache_key))
results = osrf.cache.CacheClient().get(cache_key)
for res in results:
for rec in res['records']:
- logging.info('cache_id ' + str(rec['cache_id']))
if str(rec['cache_id']) == str(rec_id):
- logging.info(unicode(rec))
c.oils.acq.record = rec
return render('oils/%s/acq/rdetails.html' % c.oils.core.skin)
- return ''
+ return 'exception -> no record'
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py 2007-12-21 14:04:18 UTC (rev 8265)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py 2007-12-21 14:31:38 UTC (rev 8266)
@@ -3,8 +3,9 @@
import osrf.ses
import osrf.xml_obj
import oils.const
-import osrf.log, osrf.cache
+import osrf.log, osrf.cache, osrf.json
+EG_Z39_SOURCES = 'open-ils.search.z3950.retrieve_services'
EG_Z39_SEARCH = 'open-ils.search.z3950.search_class'
_z_sources = None
@@ -13,20 +14,18 @@
if _z_sources:
return _z_sources
_z_sources = osrf.ses.AtomicRequest(
- 'open-ils.search',
- 'open-ils.search.z3950.retrieve_services', ctx.core.authtoken)
+ 'open-ils.search', EG_Z39_SOURCES, ctx.core.authtoken)
return _z_sources
def flatten_record(marcxml):
import pylons
xslFile = os.path.join(os.getcwd(), pylons.config['oils_xsl_prefix'], pylons.config['oils_xsl_acq_bib'])
xformed = oilsweb.lib.util.apply_xsl(marcxml, xslFile)
- return osrf.xml_obj.XMLFlattener(xformed).parse()
+ return osrf.xml_obj.XMLFlattener(xformed, True).parse()
def multi_search(ctx, search):
ses = osrf.ses.ClientSession(oils.const.OILS_APP_SEARCH)
req = ses.request(EG_Z39_SEARCH, ctx.core.authtoken, search)
- osrf.log.log_debug("sending " + unicode(search))
cache_id = 0
results = []
@@ -42,7 +41,6 @@
results.append(res)
- osrf.log.log_debug("got " + unicode(results))
return results, cache_search(search, results)
def cache_search(search, results):
@@ -52,3 +50,15 @@
osrf.cache.CacheClient().put(key, results)
return key
+def extract_bib_field(rec, field, all=False):
+ f = rec['extracts'].get("bibdata." + field)
+ if not f: return ""
+ obj = osrf.json.to_object(f)
+ if isinstance(obj, list):
+ if all:
+ return obj
+ else:
+ return obj[0]
+ else:
+ return obj
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2007-12-21 14:04:18 UTC (rev 8265)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2007-12-21 14:31:38 UTC (rev 8266)
@@ -12,29 +12,24 @@
% for rec in res['records']:
<tr class='oils-acq-pl_builder-records-title-row'>
<td rowspan='3'>
- <%
- isbn = rec["extracts"].get("bibdata.isbns.isbn")
- if isinstance(isbn, list):
- isbn = isbn[0]
- %>
<img class='oils-acq-pl_builder-records-jacket'
- src='${c.oils.core.ac_prefix}/jacket/small/${isbn}'/>
+ src='${c.oils.core.ac_prefix}/jacket/small/${c.oils.acq.extract_bib_field(rec,"isbns.isbn")}'/>
</td>
<td>
- <a href='rdetails?${c.oils.make_query_string()}&${c.oils.acq.record_id_.cgi_name}=${rec["cache_id"]}&${c.oils.acq.search_cache_key_.cgi_name}=${c.oils.acq.search_cache_key}'>${rec['extracts'].get("bibdata.title")}</a>
+ <a href='rdetails?${c.oils.make_query_string()}&${c.oils.acq.record_id_.cgi_name}=${rec["cache_id"]}&${c.oils.acq.search_cache_key_.cgi_name}=${c.oils.acq.search_cache_key}'>${c.oils.acq.extract_bib_field(rec, 'title')}</a>
</td>
- <td>${isbn}</td>
+ <td>${c.oils.acq.extract_bib_field(rec, 'isbns.isbn')}</td>
<td>${res['service']}</td>
</tr>
</tr>
<tr class='oils-acq-pl_builder-records-author-row'>
- <td colspan='3'>${rec['extracts'].get("bibdata.author")}</td>
+ <td colspan='3'>${c.oils.acq.extract_bib_field(rec, 'author')}</td>
</tr>
<tr class='oils-acq-pl_builder-records-phys_desc-row'>
<td colspan='3'>
- ${rec['extracts'].get('bibdata.pubdate')} |
- ${rec['extracts'].get('bibdata.physicalSize')}
+ ${c.oils.acq.extract_bib_field(rec, 'pubdate')} |
+ ${c.oils.acq.extract_bib_field(rec, 'physicalSize')}
</td>
</tr>
% endfor
More information about the open-ils-commits
mailing list