from mod_python import apache import traceback, codecs, sys, os from PyZ3950.asn1 import Ctx, IncrementalDecodeCtx, GeneralString from PyZ3950 import asn1, CQLUtils, ccl from PyZ3950.z3950_2001 import * from cheshire3.web.z3950_utils import * from PyZ3950.zdefs import * from PyZ3950 import oids import random rand = random.Random() from PyZ3950 import CQLParser asn1.register_oid(Z3950_QUERY_SQL, SQLQuery) asn1.register_oid(Z3950_QUERY_CQL, asn1.GeneralString) from cheshire3.baseObjects import Session, Database, Transformer, Workflow from cheshire3.server import SimpleServer from cheshire3 import internal from cheshire3 import cqlParser cheshirePath = os.environ.get('C3HOME', '/home/cheshire') session = Session() session.environment = "apache" server = SimpleServer( session, os.path.join(cheshirePath, 'cheshire3', 'configs', 'serverConfig.xml')) configs = {}
# * Check database # * Respect recordSyntax # * Respect elementsetname from PyZ3950.asn1 import Ctx, IncrementalDecodeCtx, GeneralString from PyZ3950 import asn1, CQLUtils from PyZ3950.z3950_2001 import * from z3950_utils import * from PyZ3950.zdefs import * from PyZ3950.oids import * from mod_python import apache import traceback, codecs, sys, os import PyZ3950.CQLParser as cql asn1.register_oid(Z3950_QUERY_SQL, SQLQuery) asn1.register_oid(Z3950_QUERY_CQL, asn1.GeneralString) from server import SimpleServer os.chdir("/home/cheshire/c3/code") serv = SimpleServer('/home/cheshire/c3/code/configs/serverConfig.xml') l5r = serv.get_object(None, 'db_l5r') recStore = l5r.get_object(None, 'l5rRecordStore') rss = serv.get_object(None, 'defaultResultSetStore') rsidmap = {} LOGFILE = "/home/cheshire/c3/code/logs/log.txt" class ZHandler: connection = None
"""CQL utility functions and subclasses""" from CQLParser import * from types import ListType, IntType from SRWDiagnostics import * from PyZ3950 import z3950, asn1, oids from PyZ3950.zdefs import make_attr asn1.register_oid(oids.Z3950_QUERY_CQL, asn1.GeneralString) class ZCQLConfig: contextSets = { 'dc': 'info:srw/cql-context-set/1/dc-v1.1', 'cql': 'info:srw/cql-context-set/1/cql-v1.1', 'bath': 'http://zing.z3950.org/cql/bath/2.0/', 'zthes': 'http://zthes.z3950.org/cql/1.0/', 'ccg': 'http://srw.cheshire3.org/contextSets/ccg/1.1/ ', 'rec': 'info:srw/cql-context-set/2/rec-1.0', 'net': 'info:srw/cql-context-set/2/net-1.0' } dc = { 'title': 4, 'subject': 21, 'creator': 1003, 'author': 1003, 'editor': 1020, 'contributor': 1018,
# implement piggyback # implement schema (Non useful) # implement setname (Impossible?) from PyZ3950 import z3950 from PyZ3950 import ccl from PyZ3950 import asn1 from PyZ3950 import zmarc from PyZ3950 import bib1msg from PyZ3950 import grs1 from PyZ3950 import oids # Azaroth 2003-12-04: from PyZ3950 import CQLParser, SRWDiagnostics, pqf from PyZ3950 import c2query as c2 asn1.register_oid(oids.Z3950_QUERY_SQL, z3950.SQLQuery) def my_enumerate(l): # replace w/ enumerate when we go to Python 2.3 return zip(range(len(l)), l) trace_extract = 0 """trace extracting records from search/present reqs""" class ZoomError(Exception): """Base class for all errors reported from this module""" pass
# implement schema (Non useful) # implement setname (Impossible?) from PyZ3950 import z3950 from PyZ3950 import ccl from PyZ3950 import asn1 from PyZ3950 import zmarc from PyZ3950 import bib1msg from PyZ3950 import grs1 from PyZ3950 import oids # Azaroth 2003-12-04: from PyZ3950 import CQLParser, SRWDiagnostics, pqf from PyZ3950 import c2query as c2 asn1.register_oid(oids.Z3950_QUERY_SQL, z3950.SQLQuery) def my_enumerate(l): # replace w/ enumerate when we go to Python 2.3 return zip(range(len(l)), l) trace_extract = 0 """trace extracting records from search/present reqs""" class ZoomError(Exception): """Base class for all errors reported from this module""" pass
"""CQL utility functions and subclasses""" from CQLParser import * from types import ListType, IntType from SRWDiagnostics import * from PyZ3950 import z3950, asn1, oids from PyZ3950.zdefs import make_attr asn1.register_oid (oids.Z3950_QUERY_CQL, asn1.GeneralString) class ZCQLConfig: contextSets = {'dc' : 'info:srw/cql-context-set/1/dc-v1.1', 'cql' : 'info:srw/cql-context-set/1/cql-v1.1', 'bath' : 'http://zing.z3950.org/cql/bath/2.0/', 'zthes' : 'http://zthes.z3950.org/cql/1.0/', 'ccg' : 'http://srw.cheshire3.org/contextSets/ccg/1.1/ ', 'rec' : 'info:srw/cql-context-set/2/rec-1.0', 'net' : 'info:srw/cql-context-set/2/net-1.0'} dc = {'title' : 4, 'subject' : 21, 'creator' : 1003, 'author' : 1003, 'editor' : 1020, 'contributor' : 1018, 'publisher' : 1018, 'description' : 62, 'date' : 30,
TaggedElement = asn1.SEQUENCE ([ ('tagType', 1, asn1.INTEGER, 1), ('tagValue', asn1.EXPLICIT(2), StringOrNumeric), ('tagOccurrence', 3, asn1.INTEGER, 1), ('content', asn1.EXPLICIT(4), ElementData), ('metaData', 5, ElementMetaData, 1), # set to ElementMetaData below ('appliedVariant', 6, Variant, 1) ]) ElementData.set_arm (12, ('subtree', asn1.EXPLICIT(6), asn1.SEQUENCE_OF (TaggedElement))) GenericRecord = asn1.SEQUENCE_OF(TaggedElement) asn1.register_oid (asn1.OidVal (Z3950_RECSYN_GRS1), GenericRecord) # OPAC stuff Volume = asn1.SEQUENCE ([ ('enumeration', 1, InternationalString, 1), ('chronology', 2, InternationalString, 1), ('enumAndChron', 3, InternationalString, 1)]) CircRecord = asn1.SEQUENCE ([ ('availableNow', 1, asn1.BOOLEAN), ('availablityDate', 2, InternationalString, 1), ('availableThru', 3, InternationalString, 1), ('restrictions', 4, InternationalString, 1),