From: erickson Date: Thu, 20 Dec 2007 21:59:31 +0000 (+0000) Subject: added results caching. added slim record details page. basic style changes to make... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=862acaa6830a906828f817f7113f5799a74aa4af;p=Evergreen.git added results caching. added slim record details page. basic style changes to make it less visually offensive git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8257 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py index 8affc7a0d0..e881b71043 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py @@ -1,10 +1,11 @@ -import logging - from oilsweb.lib.base import * -import pylons, os + +import logging +import pylons import oilsweb.lib.context import oilsweb.lib.util import oilsweb.lib.acq.search +import osrf.cache from oilsweb.lib.context import Context, SubContext, ContextItem log = logging.getLogger(__name__) @@ -16,7 +17,9 @@ class AcqContext(SubContext): self.search_class = ContextItem(cgi_name='acq.sc', multi=True) self.search_source = ContextItem(cgi_name='acq.ss', multi=True) self.picked_records = ContextItem(cgi_name='acq.sr', multi=True) - + self.search_cache_key = ContextItem(cgi_name='acq.sk') + self.record_id = ContextItem(cgi_name='acq.r') + self.record = ContextItem(cgi_name='acq.r') Context.applySubContext('acq', AcqContext) @@ -44,12 +47,11 @@ class AcqController(BaseController): # add logic to see where we are fetching bib data from if c.oils.acq.search_source: - c.oils_acq_records = self._build_z39_search(c.oils) + c.oils_acq_records, c.oils.acq.search_cache_key = self._build_z39_search(c.oils) return render('oils/%s/acq/pl_builder.html' % c.oils.core.skin) - def _build_z39_search(self, ctx): search = { @@ -62,8 +64,8 @@ class AcqController(BaseController): # collect the sources and credentials for src in c.oils.acq.search_source: search['service'].append(src) - search['username'].append("") # XXX - search['password'].append("") # XXX + search['username'].append("") # XXX config values? in-db? + search['password'].append("") # XXX config values? in-db? # collect the search classes for cls in c.oils.acq.search_class: @@ -72,5 +74,23 @@ class AcqController(BaseController): return oilsweb.lib.acq.search.multi_search(ctx, search) + def rdetails(self): + 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 '' + + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py index a21225b1e4..dd30e55d08 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py @@ -1,9 +1,9 @@ -import os +import os, md5 import oilsweb.lib.context import osrf.ses import osrf.xml_obj import oils.const -import osrf.log +import osrf.log, osrf.cache EG_Z39_SEARCH = 'open-ils.search.z3950.search_class' _z_sources = None @@ -28,6 +28,7 @@ def multi_search(ctx, search): req = ses.request(EG_Z39_SEARCH, ctx.core.authtoken, search) osrf.log.log_debug("sending " + unicode(search)) + cache_id = 0 results = [] while not req.complete: resp = req.recv(60) @@ -36,9 +37,18 @@ def multi_search(ctx, search): res = resp.content() for rec in res['records']: rec['extracts'] = flatten_record(rec['marcxml']) + rec['cache_id'] = cache_id + cache_id += 1 + results.append(res) osrf.log.log_debug("got " + unicode(results)) - return results - + return results, cache_search(search, results) + +def cache_search(search, results): + key = md5.new() + key.update(unicode(search)) + key = key.hexdigest() + osrf.cache.CacheClient().put(key, results) + return key diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/context.py b/Open-ILS/web/oilsweb/oilsweb/lib/context.py index 30c33fc63e..18176d82e2 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/context.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/context.py @@ -32,9 +32,11 @@ class Context(object): if val != f.default_value: if isinstance(val, list): for v in val: - q += f.cgi_name+'='+cgi.escape(v)+'&' + if isinstance(val, str) or isinstance(val, unicode): + q += f.cgi_name+'='+cgi.escape(v)+'&' else: - q += f.cgi_name+'='+cgi.escape(val)+'&' + if isinstance(val, str) or isinstance(val, unicode): + q += f.cgi_name+'='+cgi.escape(val)+'&' if len(q) > 0: q = q[:-1] # strip the trailing & return q diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css index 579e9a40af..d313aed07f 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css @@ -9,5 +9,10 @@ .oils-acq-search-form-label {} .oils-acq-search-form-input {} -#oils-acq-pl_builder-table td { padding: 3px; } +#oils-acq-pl_builder-table td {} +.oils-acq-pl_builder-records-jacket { width: 42px; height: 54px; padding-left: 10px; } +.oils-acq-pl_builder-records-title-row {} +.oils-acq-pl_builder-records-author-row td { padding-left: 30px; } +.oils-acq-pl_builder-records-phys_desc-row td { padding-left: 30px; } +.oils-acq-pl_builder-records-phys_desc-row {} diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css index 02a2dc1587..5b6627ecc4 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css @@ -7,4 +7,4 @@ #oils-acq-search-z39-sources-table tbody td { width: 33%; } #oils-acq-search-sources-label { font-weight: bold; } #oils-acq-pl_builder-table thead td { font-weight: bold; } -#oils-acq-pl_builder-table td { border-bottom: 1px solid green;} +#oils-acq-pl_builder-table td { border-bottom: 1px solid #808080;} diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css index 60eee7406e..6808bef3c1 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css @@ -5,10 +5,10 @@ body { font-size: 85%; } /* base default style */ #oils-base-body-block {} -#oils-base-navigate-block {border: 1px solid green;} +#oils-base-navigate-block {border: 1px solid #808080;} #oils-base-content-block {} -#oils-base-sidebar-block {border: 1px solid red;} -#oils-base-footer-block {padding: 3px; margin-top: 20px; border: 1px solid green;} +#oils-base-sidebar-block {} +#oils-base-footer-block {padding: 3px; margin-top: 20px; border: 1px solid #808080;} diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html index 511373179b..df835e9050 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html @@ -2,18 +2,41 @@ <%def name="block_title()">${_('Evergreen Acquisitions Results')} <%def name="block_content()"> + % for res in c.oils_acq_records: % for rec in res['records']: - - - - + + + + + + + + + + + + % endfor % endfor diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html new file mode 100644 index 0000000000..1c8244306f --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html @@ -0,0 +1,13 @@ +<%inherit file='../base.html'/> +<%def name="block_title()">${_('Evergreen ACQ Details')} +<%def name="block_content()"> +
${rec['extracts'].get("bibdata.title")}${rec['extracts'].get("bibdata.author")}
+ <% + isbn = rec["extracts"].get("bibdata.isbns.isbn") + if isinstance(isbn, list): + isbn = isbn[0] + %> + + + ${rec['extracts'].get("bibdata.title")} + ${isbn} ${res['service']}
${rec['extracts'].get("bibdata.author")}
+ ${rec['extracts'].get('bibdata.pubdate')} | + ${rec['extracts'].get('bibdata.physicalSize')} +
+ % for key,val in c.oils.acq.record['extracts'].iteritems(): + + + + + % endfor +
${key}${val}
+ +