[open-ils-commits] r8257 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers lib lib/acq public/oils/media/css/skin
public/oils/media/css/theme templates/oils/default/acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 20 17:21:19 EST 2007
Author: erickson
Date: 2007-12-20 16:59:31 -0500 (Thu, 20 Dec 2007)
New Revision: 8257
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html
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/lib/context.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
Log:
added results caching. added slim record details page. basic style changes to make it less visually offensive
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-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py 2007-12-20 21:59:31 UTC (rev 8257)
@@ -1,10 +1,11 @@
+from oilsweb.lib.base import *
+
import logging
-
-from oilsweb.lib.base import *
-import pylons, os
+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 @@
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 @@
# 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 @@
# 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 @@
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 ''
+
+
+
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-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py 2007-12-20 21:59:31 UTC (rev 8257)
@@ -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 @@
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 @@
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
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2007-12-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2007-12-20 21:59:31 UTC (rev 8257)
@@ -32,9 +32,11 @@
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
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css 2007-12-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css 2007-12-20 21:59:31 UTC (rev 8257)
@@ -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 {}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css 2007-12-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/acq_default.css 2007-12-20 21:59:31 UTC (rev 8257)
@@ -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;}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css 2007-12-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css 2007-12-20 21:59:31 UTC (rev 8257)
@@ -5,10 +5,10 @@
/* 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;}
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-20 21:58:00 UTC (rev 8256)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2007-12-20 21:59:31 UTC (rev 8257)
@@ -2,18 +2,41 @@
<%def name="block_title()">${_('Evergreen Acquisitions Results')}</%def>
<%def name="block_content()">
<table id='oils-acq-pl_builder-table'>
+ <!--
<thead>
<tr><td>${_('Add To Picklist')}</td><td>${_('Title')}</td><td>${_('Author')}</td><td>${_('Source')}</td></tr>
</thead>
+ -->
<tbody>
% for res in c.oils_acq_records:
% for rec in res['records']:
- <tr>
- <td><input type='checkbox' name='${c.oils.acq.picked_records_.cgi_name}' value='blah'/></td>
- <td>${rec['extracts'].get("bibdata.title")}</td>
- <td>${rec['extracts'].get("bibdata.author")}</td>
+ <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}'/>
+ </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>
+ </td>
+ <td>${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>
+ </tr>
+ <tr class='oils-acq-pl_builder-records-phys_desc-row'>
+ <td colspan='3'>
+ ${rec['extracts'].get('bibdata.pubdate')} |
+ ${rec['extracts'].get('bibdata.physicalSize')}
+ </td>
+ </tr>
% endfor
% endfor
</tbody>
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html 2007-12-20 21:59:31 UTC (rev 8257)
@@ -0,0 +1,13 @@
+<%inherit file='../base.html'/>
+<%def name="block_title()">${_('Evergreen ACQ Details')}</%def>
+<%def name="block_content()">
+ <table>
+ % for key,val in c.oils.acq.record['extracts'].iteritems():
+ <tr>
+ <td>${key}</td>
+ <td>${val}</td>
+ </tr>
+ % endfor
+ </table>
+</%def>
+
More information about the open-ils-commits
mailing list