remove 'zsearch', an old testing function.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 3 Apr 2011 01:24:51 +0000 (01:24 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 3 Apr 2011 01:24:51 +0000 (01:24 +0000)
With this out of the way, I can now load Syrup without any integration
module. (zsearch's dependency on PyZ3950 was, indirectly, troublesome).

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1309 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/syrup/urls.py
conifer/syrup/views/search.py

index bda717d..3fbcb3c 100644 (file)
@@ -19,7 +19,6 @@ urlpatterns = patterns('conifer.syrup.views',
     #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'),
index 9d49597..dbcc558 100644 (file)
@@ -1,6 +1,4 @@
 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
@@ -154,98 +152,3 @@ def search(request, in_site=None, for_owner=None):
         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)