viewvc-4intranet/lib/query.py

495 lines
15 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*-python-*-
#
# Copyright (C) 1999-2013 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html.
#
# For more information, visit http://viewvc.org/
#
# -----------------------------------------------------------------------
#
# CGI script to process and display queries to CVSdb
#
# This script is part of the ViewVC package. More information can be
# found at http://viewvc.org
#
# -----------------------------------------------------------------------
import os
import sys
import string
import time
from common import _item, TemplateData
import cvsdb
import viewvc
import ezt
import debug
import urllib
import fnmatch
class FormData:
def __init__(self, form):
self.valid = 0
self.repository = ""
self.branch = ""
self.directory = ""
self.file = ""
self.who = ""
self.sortby = ""
self.textquery = ""
self.date = ""
self.hours = 0
self.decode_thyself(form)
def decode_thyself(self, form):
try:
self.textquery = string.strip(form["textquery"].value)
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.repository = form["repository"].value.strip()
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.branch = form["branch"].value.strip()
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.directory = form["directory"].value.strip()
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.file = form["file"].value.strip()
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.who = form["who"].value.strip()
except KeyError:
pass
except TypeError:
pass
else:
self.valid = 1
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.sortby = form["sortby"].value.strip()
except KeyError:
pass
except TypeError:
pass
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
self.date = form["date"].value.strip()
except KeyError:
pass
except TypeError:
pass
try:
self.hours = int(form["hours"].value)
except KeyError:
pass
except TypeError:
pass
except ValueError:
pass
else:
self.valid = 1
## returns a tuple-list (mod-str, string)
def listparse_string(str):
return_list = []
cmd = ""
temp = ""
escaped = 0
state = "eat leading whitespace"
for c in str:
## handle escaped charactors
if not escaped and c == "\\":
escaped = 1
continue
## strip leading white space
if state == "eat leading whitespace":
if c in string.whitespace:
continue
else:
state = "get command or data"
## parse to '"' or ","
if state == "get command or data":
## just add escaped charactors
if escaped:
escaped = 0
temp = temp + c
continue
## the data is in quotes after the command
elif c == "\"":
cmd = temp
temp = ""
state = "get quoted data"
continue
## this tells us there was no quoted data, therefore no
## command; add the command and start over
elif c == ",":
## strip ending whitespace on un-quoted data
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
temp = temp.rstrip()
return_list.append( ("", temp) )
temp = ""
state = "eat leading whitespace"
continue
## record the data
else:
temp = temp + c
continue
## parse until ending '"'
if state == "get quoted data":
## just add escaped charactors
if escaped:
escaped = 0
temp = temp + c
continue
## look for ending '"'
elif c == "\"":
return_list.append( (cmd, temp) )
cmd = ""
temp = ""
state = "eat comma after quotes"
continue
## record the data
else:
temp = temp + c
continue
## parse until ","
if state == "eat comma after quotes":
if c in string.whitespace:
continue
elif c == ",":
state = "eat leading whitespace"
continue
else:
print "format error"
sys.exit(1)
if cmd or temp:
return_list.append((cmd, temp))
return return_list
def decode_command(cmd):
if cmd == "r":
return "regex"
elif cmd == "l":
return "like"
else:
return "exact"
def form_to_cvsdb_query(cfg, form_data):
query = cvsdb.CreateCheckinQuery()
query.SetLimit(cfg.cvsdb.row_limit)
if form_data.repository:
for cmd, str in listparse_string(form_data.repository):
cmd = decode_command(cmd)
query.SetRepository(str, cmd)
if form_data.branch:
for cmd, str in listparse_string(form_data.branch):
cmd = decode_command(cmd)
query.SetBranch(str, cmd)
if form_data.directory:
for cmd, str in listparse_string(form_data.directory):
cmd = decode_command(cmd)
query.SetDirectory(str, cmd)
if form_data.file:
for cmd, str in listparse_string(form_data.file):
cmd = decode_command(cmd)
query.SetFile(str, cmd)
if form_data.who:
for cmd, str in listparse_string(form_data.who):
cmd = decode_command(cmd)
query.SetAuthor(str, cmd)
if form_data.textquery:
query.SetTextQuery(form_data.textquery)
if form_data.sortby == "author":
query.SetSortMethod("author")
elif form_data.sortby == "file":
query.SetSortMethod("file")
elif form_data.sortby == "relevance" and form_data.textquery:
query.SetSortMethod("relevance")
else:
query.SetSortMethod("date")
if form_data.date:
if form_data.date == "hours" and form_data.hours:
query.SetFromDateHoursAgo(form_data.hours)
elif form_data.date == "day":
query.SetFromDateDaysAgo(1)
elif form_data.date == "week":
query.SetFromDateDaysAgo(7)
elif form_data.date == "month":
query.SetFromDateDaysAgo(31)
return query
def prev_rev(rev):
'''Returns a string representing the previous revision of the argument.'''
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
r = rev.split('.')
# decrement final revision component
r[-1] = str(int(r[-1]) - 1)
# prune if we pass the beginning of the branch
if len(r) > 2 and r[-1] == '0':
r = r[:-2]
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
return '.'.join(r)
def is_forbidden(cfg, cvsroot_name, module):
Some security-related improvements/fixes. Make per-root authorizer-related configuration work so that admins can feel comfortable exposing their root listing views again. Also, make the query interface require that queried roots be configured (explicitly or implicitly) to use either the 'forbidden' authorizer or none at all. This is a security fix, since administrators might reasonably have thought that if they configured a root to use another authorizer, the query interface would have honored that configuration. * lib/config.py (Config.__init__): Now track whether root options have been overlayed. (Config.overlay_root_options): Assert that no root options have been overlayed (and then noted that they now have). (Config.get_authorizer_and_params_hack): New function to workaround our inability to un-overlay root-specific options. It's only the query interface and root listing views that really need to act on multiple roots at once, and really only the authorization options that matter there anyway. (Config.get_authorizer_params): Remove per-root overlay hacks from this function. * lib/viewvc.py (Request.run_viewvc): Update call to setup_authorizer() (to not specify the rootname). (setup_authorizer): Make the rootname parameter option, as a flag for whether to consult the current configuration or instead use the hack which manually digs around for per-root overrides of authorizer stuffs. * lib/query.py (is_forbidden): Don't try to apply the 'forbidden' authorizer where some other (or no) authorizer has been configured for a given root. But do complain if another authorizer has been configured, rather than simply letting stuff leak through that an administrator might reasonably expect to have been hidden. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2300 8cb11bc2-c004-0410-86c3-e597b4017df7
2009-12-03 09:04:32 +03:00
'''Return 1 if MODULE in CVSROOT_NAME is forbidden; return 0 otherwise.'''
# CVSROOT_NAME might be None here if the data comes from an
# unconfigured root. This interfaces doesn't care that the root
# isn't configured, but if that's the case, it will consult only
# the base and per-vhost configuration for authorizer and
# authorizer parameters.
if cvsroot_name:
cfg = cfg.get_root_config(cvsroot_name)
authorizer = cfg.options.authorizer
params = cfg.get_authorizer_params()
Some security-related improvements/fixes. Make per-root authorizer-related configuration work so that admins can feel comfortable exposing their root listing views again. Also, make the query interface require that queried roots be configured (explicitly or implicitly) to use either the 'forbidden' authorizer or none at all. This is a security fix, since administrators might reasonably have thought that if they configured a root to use another authorizer, the query interface would have honored that configuration. * lib/config.py (Config.__init__): Now track whether root options have been overlayed. (Config.overlay_root_options): Assert that no root options have been overlayed (and then noted that they now have). (Config.get_authorizer_and_params_hack): New function to workaround our inability to un-overlay root-specific options. It's only the query interface and root listing views that really need to act on multiple roots at once, and really only the authorization options that matter there anyway. (Config.get_authorizer_params): Remove per-root overlay hacks from this function. * lib/viewvc.py (Request.run_viewvc): Update call to setup_authorizer() (to not specify the rootname). (setup_authorizer): Make the rootname parameter option, as a flag for whether to consult the current configuration or instead use the hack which manually digs around for per-root overrides of authorizer stuffs. * lib/query.py (is_forbidden): Don't try to apply the 'forbidden' authorizer where some other (or no) authorizer has been configured for a given root. But do complain if another authorizer has been configured, rather than simply letting stuff leak through that an administrator might reasonably expect to have been hidden. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2300 8cb11bc2-c004-0410-86c3-e597b4017df7
2009-12-03 09:04:32 +03:00
# If CVSROOT_NAME isn't configured to use an authorizer, nothing
# is forbidden. If it's configured to use something other than
# the 'forbidden' authorizer, complain. Otherwise, check for
# forbiddenness per the PARAMS as expected.
if not authorizer:
return 0
if authorizer != 'forbidden':
raise Exception("The 'forbidden' authorizer is the only one supported "
"by this interface. The '%s' root is configured to "
"use a different one." % (cvsroot_name))
forbidden = params.get('forbidden', '')
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
forbidden = map(lambda x: x.strip(), filter(None, forbidden.split(',')))
default = 0
for pat in forbidden:
if pat[0] == '!':
default = 1
if fnmatch.fnmatchcase(module, pat[1:]):
return 0
elif fnmatch.fnmatchcase(module, pat):
return 1
return default
def build_commit(server, cfg, desc, files, cvsroots, viewvc_link):
ob = _item(num_files=len(files), files=[])
2013-07-18 19:13:28 +04:00
ob.log = desc and server.escape(desc).replace('\n', '<br />') or '&nbsp;'
for commit in files:
repository = commit.GetRepository()
directory = commit.GetDirectory()
cvsroot_name = cvsroots.get(repository)
## find the module name (if any)
try:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
module = filter(None, directory.split('/'))[0]
except IndexError:
module = None
## skip commits we aren't supposed to show
if module and ((module == 'CVSROOT' and cfg.options.hide_cvsroot) \
or is_forbidden(cfg, cvsroot_name, module)):
continue
ctime = commit.GetTime()
if not ctime:
ctime = "&nbsp;"
else:
if (cfg.options.use_localtime):
ctime = time.strftime("%y/%m/%d %H:%M %Z", time.localtime(ctime))
else:
ctime = time.strftime("%y/%m/%d %H:%M", time.gmtime(ctime)) \
+ ' UTC'
## make the file link
try:
file = (directory and directory + "/") + commit.GetFile()
except:
raise Exception, str([directory, commit.GetFile()])
## If we couldn't find the cvsroot path configured in the
## viewvc.conf file, or we don't have a VIEWVC_LINK, then
## don't make the link.
if cvsroot_name and viewvc_link:
flink = '[%s] <a href="%s/%s?root=%s">%s</a>' % (
cvsroot_name, viewvc_link, urllib.quote(file),
cvsroot_name, file)
if commit.GetType() == commit.CHANGE:
dlink = '%s/%s?root=%s&amp;view=diff&amp;r1=%s&amp;r2=%s' % (
viewvc_link, urllib.quote(file), cvsroot_name,
prev_rev(commit.GetRevision()), commit.GetRevision())
else:
dlink = None
else:
flink = '[%s] %s' % (repository, file)
dlink = None
ob.relevance = commit.GetRelevance()
ob.plus += int(commit.GetPlusCount())
ob.minus += int(commit.GetMinusCount())
ob.files.append(_item(date=ctime,
author=commit.GetAuthor(),
link=flink,
rev=commit.GetRevision(),
branch=commit.GetBranch(),
plus=int(commit.GetPlusCount()),
minus=int(commit.GetMinusCount()),
type=commit.GetTypeString(),
difflink=dlink,
))
return ob
def run_query(server, cfg, db, form_data, viewvc_link):
query = form_to_cvsdb_query(cfg, form_data)
db.RunQuery(query)
Fix (to the degree that I believe is reasonable at this time) issue #433 ("queries return only partial results"). When a database query is artificially limited by the 'row_limit' setting, inform the user that the returned data is incomplete. * lib/cvsdb.py (CheckinDatabase.CreateSQLQueryString): Add 'detect_leftover' parameter, used internally to check for a reached query limit. (CheckinDatabase.RunQuery): Update call to CreateSQLQueryString(), and check for leftover query response rows. If any are found, set the appropriate flag on the query object. (CheckinDatabaseQuery.__init__): Set initial values for new 'executed' and 'limit_reached' members. (CheckinDatabaseQuery.SetExecuted, CheckinDatabaseQuery.SetLimitReached, CheckinDatabaseQuery.GetLimitReached, CheckinDatabaseQuery.GetCommitList): New functions. * lib/viewvc.py (view_query): Use query.GetCommitList() now instead of poking into the query object directly. Also, check query.GetLimitReached(), reporting the findings through the data dictionary (via a new 'row_limit_reached' item) to the templates. * lib/query.py (run_query): Use query.GetCommitList() now instead of poking into the query object directly. Now return a 2-tuple of commits and a limit-reached flag. (main): Update expectations of run_query() call. Populate 'row_limit_reached' data dictionary item. * templates/query_results.ezt, * templates/query.ezt Display a warning if the query results are incomplete. * templates/docroot/styles.css (.vc_warning): New style definition. * docs/template-authoring-guide.html Document the new 'row_limit_reached' template item. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2551 8cb11bc2-c004-0410-86c3-e597b4017df7
2011-04-20 18:50:40 +04:00
commit_list = query.GetCommitList()
if not commit_list:
return [ ], 0
row_limit_reached = query.GetLimitReached()
commits = [ ]
files = [ ]
cvsroots = {}
viewvc.expand_root_parents(cfg)
rootitems = cfg.general.svn_roots.items() + cfg.general.cvs_roots.items()
for key, value in rootitems:
cvsroots[cvsdb.CleanRepository(value)] = key
Fix (to the degree that I believe is reasonable at this time) issue #433 ("queries return only partial results"). When a database query is artificially limited by the 'row_limit' setting, inform the user that the returned data is incomplete. * lib/cvsdb.py (CheckinDatabase.CreateSQLQueryString): Add 'detect_leftover' parameter, used internally to check for a reached query limit. (CheckinDatabase.RunQuery): Update call to CreateSQLQueryString(), and check for leftover query response rows. If any are found, set the appropriate flag on the query object. (CheckinDatabaseQuery.__init__): Set initial values for new 'executed' and 'limit_reached' members. (CheckinDatabaseQuery.SetExecuted, CheckinDatabaseQuery.SetLimitReached, CheckinDatabaseQuery.GetLimitReached, CheckinDatabaseQuery.GetCommitList): New functions. * lib/viewvc.py (view_query): Use query.GetCommitList() now instead of poking into the query object directly. Also, check query.GetLimitReached(), reporting the findings through the data dictionary (via a new 'row_limit_reached' item) to the templates. * lib/query.py (run_query): Use query.GetCommitList() now instead of poking into the query object directly. Now return a 2-tuple of commits and a limit-reached flag. (main): Update expectations of run_query() call. Populate 'row_limit_reached' data dictionary item. * templates/query_results.ezt, * templates/query.ezt Display a warning if the query results are incomplete. * templates/docroot/styles.css (.vc_warning): New style definition. * docs/template-authoring-guide.html Document the new 'row_limit_reached' template item. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2551 8cb11bc2-c004-0410-86c3-e597b4017df7
2011-04-20 18:50:40 +04:00
current_desc = commit_list[0].GetDescription()
for commit in commit_list:
desc = commit.GetDescription()
if current_desc == desc:
files.append(commit)
continue
commits.append(build_commit(server, cfg, current_desc, files,
cvsroots, viewvc_link))
files = [ commit ]
current_desc = desc
## add the last file group to the commit list
commits.append(build_commit(server, cfg, current_desc, files,
cvsroots, viewvc_link))
# Strip out commits that don't have any files attached to them. The
# files probably aren't present because they've been blocked via
# forbiddenness.
def _only_with_files(commit):
return len(commit.files) > 0
commits = filter(_only_with_files, commits)
Fix (to the degree that I believe is reasonable at this time) issue #433 ("queries return only partial results"). When a database query is artificially limited by the 'row_limit' setting, inform the user that the returned data is incomplete. * lib/cvsdb.py (CheckinDatabase.CreateSQLQueryString): Add 'detect_leftover' parameter, used internally to check for a reached query limit. (CheckinDatabase.RunQuery): Update call to CreateSQLQueryString(), and check for leftover query response rows. If any are found, set the appropriate flag on the query object. (CheckinDatabaseQuery.__init__): Set initial values for new 'executed' and 'limit_reached' members. (CheckinDatabaseQuery.SetExecuted, CheckinDatabaseQuery.SetLimitReached, CheckinDatabaseQuery.GetLimitReached, CheckinDatabaseQuery.GetCommitList): New functions. * lib/viewvc.py (view_query): Use query.GetCommitList() now instead of poking into the query object directly. Also, check query.GetLimitReached(), reporting the findings through the data dictionary (via a new 'row_limit_reached' item) to the templates. * lib/query.py (run_query): Use query.GetCommitList() now instead of poking into the query object directly. Now return a 2-tuple of commits and a limit-reached flag. (main): Update expectations of run_query() call. Populate 'row_limit_reached' data dictionary item. * templates/query_results.ezt, * templates/query.ezt Display a warning if the query results are incomplete. * templates/docroot/styles.css (.vc_warning): New style definition. * docs/template-authoring-guide.html Document the new 'row_limit_reached' template item. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2551 8cb11bc2-c004-0410-86c3-e597b4017df7
2011-04-20 18:50:40 +04:00
return commits, row_limit_reached
def main(server, cfg, viewvc_link):
try:
form = server.FieldStorage()
form_data = FormData(form)
db = cvsdb.ConnectDatabaseReadOnly(cfg, None)
if form_data.valid:
2013-07-18 19:13:28 +04:00
commits, row_limit_reached = run_query(server, cfg, db, form_data, viewvc_link)
query = None
else:
commits = [ ]
Fix (to the degree that I believe is reasonable at this time) issue #433 ("queries return only partial results"). When a database query is artificially limited by the 'row_limit' setting, inform the user that the returned data is incomplete. * lib/cvsdb.py (CheckinDatabase.CreateSQLQueryString): Add 'detect_leftover' parameter, used internally to check for a reached query limit. (CheckinDatabase.RunQuery): Update call to CreateSQLQueryString(), and check for leftover query response rows. If any are found, set the appropriate flag on the query object. (CheckinDatabaseQuery.__init__): Set initial values for new 'executed' and 'limit_reached' members. (CheckinDatabaseQuery.SetExecuted, CheckinDatabaseQuery.SetLimitReached, CheckinDatabaseQuery.GetLimitReached, CheckinDatabaseQuery.GetCommitList): New functions. * lib/viewvc.py (view_query): Use query.GetCommitList() now instead of poking into the query object directly. Also, check query.GetLimitReached(), reporting the findings through the data dictionary (via a new 'row_limit_reached' item) to the templates. * lib/query.py (run_query): Use query.GetCommitList() now instead of poking into the query object directly. Now return a 2-tuple of commits and a limit-reached flag. (main): Update expectations of run_query() call. Populate 'row_limit_reached' data dictionary item. * templates/query_results.ezt, * templates/query.ezt Display a warning if the query results are incomplete. * templates/docroot/styles.css (.vc_warning): New style definition. * docs/template-authoring-guide.html Document the new 'row_limit_reached' template item. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2551 8cb11bc2-c004-0410-86c3-e597b4017df7
2011-04-20 18:50:40 +04:00
row_limit_reached = 0
query = 'skipped'
docroot = cfg.options.docroot
if docroot is None and viewvc_link:
docroot = viewvc_link + '/' + viewvc.docroot_magic_path
data = TemplateData({
'cfg' : cfg,
'address' : cfg.general.address,
'vsn' : viewvc.__version__,
2013-07-18 19:13:28 +04:00
'textquery' : server.escape(form_data.textquery),
'repository' : server.escape(form_data.repository),
'branch' : server.escape(form_data.branch),
'directory' : server.escape(form_data.directory),
'file' : server.escape(form_data.file),
'who' : server.escape(form_data.who),
'docroot' : docroot,
'sortby' : form_data.sortby,
'date' : form_data.date,
'query' : query,
Fix (to the degree that I believe is reasonable at this time) issue #433 ("queries return only partial results"). When a database query is artificially limited by the 'row_limit' setting, inform the user that the returned data is incomplete. * lib/cvsdb.py (CheckinDatabase.CreateSQLQueryString): Add 'detect_leftover' parameter, used internally to check for a reached query limit. (CheckinDatabase.RunQuery): Update call to CreateSQLQueryString(), and check for leftover query response rows. If any are found, set the appropriate flag on the query object. (CheckinDatabaseQuery.__init__): Set initial values for new 'executed' and 'limit_reached' members. (CheckinDatabaseQuery.SetExecuted, CheckinDatabaseQuery.SetLimitReached, CheckinDatabaseQuery.GetLimitReached, CheckinDatabaseQuery.GetCommitList): New functions. * lib/viewvc.py (view_query): Use query.GetCommitList() now instead of poking into the query object directly. Also, check query.GetLimitReached(), reporting the findings through the data dictionary (via a new 'row_limit_reached' item) to the templates. * lib/query.py (run_query): Use query.GetCommitList() now instead of poking into the query object directly. Now return a 2-tuple of commits and a limit-reached flag. (main): Update expectations of run_query() call. Populate 'row_limit_reached' data dictionary item. * templates/query_results.ezt, * templates/query.ezt Display a warning if the query results are incomplete. * templates/docroot/styles.css (.vc_warning): New style definition. * docs/template-authoring-guide.html Document the new 'row_limit_reached' template item. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2551 8cb11bc2-c004-0410-86c3-e597b4017df7
2011-04-20 18:50:40 +04:00
'row_limit_reached' : ezt.boolean(row_limit_reached),
'commits' : commits,
'num_commits' : len(commits),
'rss_href' : None,
'repositories' : db.GetRepositoryList(),
'hours' : form_data.hours and form_data.hours or 2,
})
# generate the page
server.header()
template = viewvc.get_view_template(cfg, "query")
template.generate(server.file(), data)
except SystemExit, e:
pass
except:
exc_info = debug.GetExceptionData()
server.header(status=exc_info['status'])
debug.PrintException(server, exc_info)