query_parser.py revision 2961
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# CDDL HEADER START
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# The contents of this file are subject to the terms of the
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# Common Development and Distribution License (the "License").
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# You may not use this file except in compliance with the License.
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# See the License for the specific language governing permissions
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# and limitations under the License.
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# If applicable, add the following below this CDDL HEADER, with the
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek# fields enclosed by brackets "[]" replaced with your own identifying
9384ef699a57687ce6dbdae7d686181f4791b1e5Aki Tuomi# information: Portions Copyright [yyyy] [name of copyright owner]
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# CDDL HEADER END
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainenfrom pkg.query_parser import BooleanQueryException, ParseError, QueryException, QueryLengthExceeded
26c41874cf6019c3e39f0ed630b2a07a92b2635fJosef 'Jeff' Sipek """This class exists so that the classes the parent class query parser
26c41874cf6019c3e39f0ed630b2a07a92b2635fJosef 'Jeff' Sipek uses to build the AST are the ones defined in this module and not the
26c41874cf6019c3e39f0ed630b2a07a92b2635fJosef 'Jeff' Sipek parent class's module. This is done so that a single query parser can
26c41874cf6019c3e39f0ed630b2a07a92b2635fJosef 'Jeff' Sipek be shared between the client and server modules but will construct an
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek AST using the appropriate classes."""
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek mod = sys.modules[QueryParser.__module__]
26c41874cf6019c3e39f0ed630b2a07a92b2635fJosef 'Jeff' Sipek for class_name in self.query_objs.keys():
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek tmp[class_name] = getattr(mod, class_name)
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen# Because many classes do not have client specific modifications, they
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek# simply subclass the parent module's classes.
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek """This class handles the client specific search logic for searching
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek for a specific query term."""
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen """This function performs the specific steps needed to do
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen search on a server.
70e0c96e14bb7cf6601645b3a858ee0261230031Josef 'Jeff' Sipek The "restriction" parameter is a generator over results that
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen another branch of the AST has already found. If it's not None,
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen then it's treated as the domain for search. If it is None then
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi the actions of all known packages is the domain for search.
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen The "fmris" parameter is a function which produces an object
2c57ebc900742bd1119ef011b77b4910c4660cfaTimo Sirainen which iterates over all known fmris."""