[open-ils-commits] r1309 - in servres/trunk/conifer/syrup: . views (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Apr 2 21:24:52 EDT 2011
Author: gfawcett
Date: 2011-04-02 21:24:51 -0400 (Sat, 02 Apr 2011)
New Revision: 1309
Modified:
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/search.py
Log:
remove 'zsearch', an old testing function.
With this out of the way, I can now load Syrup without any integration
module. (zsearch's dependency on PyZ3950 was, indirectly, troublesome).
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2011-04-03 01:24:47 UTC (rev 1308)
+++ servres/trunk/conifer/syrup/urls.py 2011-04-03 01:24:51 UTC (rev 1309)
@@ -19,7 +19,6 @@
#MARK: propose we kill open_sites, we have browse.
(r'^opensite/$', 'open_sites'),
(r'^search/$', 'search'),
- (r'^zsearch/$', 'zsearch'),
#MARK: propose we kill instructors, we have browse
(r'^instructors/$', 'instructors'),
(r'^instructors/search/(?P<instructor>.*)$', 'instructor_search'),
Modified: servres/trunk/conifer/syrup/views/search.py
===================================================================
--- servres/trunk/conifer/syrup/views/search.py 2011-04-03 01:24:47 UTC (rev 1308)
+++ servres/trunk/conifer/syrup/views/search.py 2011-04-03 01:24:51 UTC (rev 1309)
@@ -1,7 +1,5 @@
from _common import *
-from PyZ3950 import zoom, zmarc
-
# ENABLE_USER_FILTERS: if True, then search results will not contain
# anything that the logged-in user would not be permitted to view. For
# example, if the user is not logged in, only "anonymous" site
@@ -154,98 +152,3 @@
norm_query = normalize_query(query_string)
return g.render('search_results.xhtml', **locals())
-
-
-
-
-
-
-
-#-----------------------------------------------------------------------------
-# Z39.50 support (for testing)
-
-def zsearch(request):
- '''
- '''
-
- page_num = int(request.GET.get('page', 1))
- count = int(request.POST.get('count', 5))
-
- if request.GET.get('page')==None and request.method == 'GET':
- targets_list = models.Z3950Target.objects.filter(active=True) \
- .order_by('name')
- targets_len = len(targets_list)
- return g.render('zsearch.xhtml', **locals())
- else:
-
- target = request.GET.get('target')
- if request.method == 'POST':
- target = request.POST['target']
- print("target is %s" % target)
-
- tquery = request.GET.get('query')
- if request.method == 'POST':
- tquery = request.POST['ztitle']
- search_target= models.Z3950Target.objects.get(name=target)
- conn = zoom.Connection (search_target.host, search_target.port)
- conn.databaseName = search_target.database
- conn.preferredRecordSyntax = search_target.syntax
- query = zoom.Query ('CCL', '%s="%s"' % ('ti',tquery))
- res = conn.search (query)
- print("results are %d" % len(res))
- collector = [(None,None)] * len(res)
-
- start = (page_num - 1) * count
- end = (page_num * count) + 1
-
- idx = start;
- for r in res[start : end]:
-
- print("-> %d" % idx)
- if r.syntax <> 'USMARC':
- collector.pop(idx)
- collector.insert (idx,(None, 'Unsupported syntax: ' + r.syntax,
- None))
- else:
- raw = r.data
-
- # Convert to MARC
- marcdata = zmarc.MARC(raw, strict=False)
- #print marcdata
-
- # Convert to MARCXML
- # marcxml = marcdata.toMARCXML()
- # print marcxml
-
- # How to Remove non-ascii characters (in case this is a problem)
- #marcxmlascii = unicode(marcxml, 'ascii', 'ignore').encode('ascii')
-
- bibid = marcdata.fields[1][0]
- title = " ".join ([v[1] for v in marcdata.fields [245][0][2]])
-
- # Amara XML tools would allow using xpath
- '''
- title = ""
- doc = binderytools.bind_string(marcxml)
- t = doc.xml_xpath("//datafield[@tag='245']/subfield[@code='a']")
- if len(title)>0:
- title = t[0].xml_text_content()
- '''
-
- # collector.append ((bibid, title))
- #this is not a good situation but will leave for now
- #collector.append ((bibid, unicode(title, 'ascii', 'ignore')))
-
- collector.pop(idx)
- # collector.insert(idx,(bibid, unicode(title,'ascii','ignore')))
- collector.insert(idx,(bibid, unicode(title, 'utf-8', 'ignore')))
- idx+=1
-
- conn.close ()
- paginator = Paginator(collector, count)
-
- print("returning...")
- #return g.render('zsearch_results.xhtml', **locals())
- return g.render('zsearch_results.xhtml', paginator=paginator,
- page_num=page_num,
- count=count, target=target, tquery=tquery)
More information about the open-ils-commits
mailing list