From: davidb Date: Mon, 28 Apr 2003 16:44:56 +0000 (+0000) Subject: copyright and license notices; fix -limit behavior X-Git-Tag: v0.2~6 X-Git-Url: https://blacka.com/cgi-bin/gitweb.cgi?p=python-rwhoisd.git;a=commitdiff_plain;h=302354493f0334d134371d46489817c650fc4a2c copyright and license notices; fix -limit behavior --- diff --git a/rwhoisd/QueryProcessor.py b/rwhoisd/QueryProcessor.py index e3bcd75..1297965 100644 --- a/rwhoisd/QueryProcessor.py +++ b/rwhoisd/QueryProcessor.py @@ -1,3 +1,24 @@ +# This file is part of python-rwhoisd +# +# Copyright (C) 2003, David E. Blacka +# +# $Id: QueryProcessor.py,v 1.3 2003/04/28 16:44:56 davidb Exp $ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + import sys, re import Cidr, Rwhois, QueryParser @@ -199,13 +220,13 @@ class QueryProcessor: # shortcut for the very common single clause case: if len(query.clauses) == 1: - res = self.process_query_clause(query.clauses[0]) + res = self.process_query_clause(query.clauses[0], max) return res # otherwise, union the results from all the causes res = QueryResult() for clause in query.clauses: - res.extend(self.process_query_clause(clause)) + res.extend(self.process_query_clause(clause), max) if max and len(res) >= max: res.truncate(max) break @@ -229,6 +250,8 @@ class QueryProcessor: max = session.limit if max: max += 1 + print "process_query: max =", max + query_result = self.process_full_query(query, max) objects = query_result.objects() @@ -239,6 +262,11 @@ class QueryProcessor: # session.wfile.write("\r\n") return + limit_exceeded = False + if session.limit and len(objects) > session.limit: + del objects[session.limit:] + limit_exceeded = True + for obj in objects: session.wfile.write(obj.to_wire_str()) session.wfile.write("\r\n") @@ -249,8 +277,8 @@ class QueryProcessor: session.wfile.write("\r\n".join(referrals)) session.wfile.write("\r\n") - if session.limit and len(objects) > session.limit: - session.wfile.write(330) + if limit_exceeded: + session.wfile.write(Rwhois.error_message(330)) else: session.wfile.write(Rwhois.ok())