X-Git-Url: https://blacka.com/cgi-bin/gitweb.cgi?p=python-rwhoisd.git;a=blobdiff_plain;f=rwhoisd%2FQueryProcessor.py;h=8725141e3213e05d12f442971d0419323c3931e5;hp=e3bcd75f6c58ba71a8b4d9d7eb98b5114ddad822;hb=HEAD;hpb=3738feba15d61d3a73e6661a8dcb66f40846f5ea diff --git a/rwhoisd/QueryProcessor.py b/rwhoisd/QueryProcessor.py index e3bcd75..8725141 100644 --- a/rwhoisd/QueryProcessor.py +++ b/rwhoisd/QueryProcessor.py @@ -1,3 +1,22 @@ +# This file is part of python-rwhoisd +# +# Copyright (C) 2003, David E. Blacka +# +# 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 +218,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 @@ -239,6 +258,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 +273,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())