+# 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
# 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
# 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")
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())