| 1 | # svntrac
|
|---|
| 2 | #
|
|---|
| 3 | # Copyright (C) 2003 Jonas Borgström <jonas@xyche.com>
|
|---|
| 4 | #
|
|---|
| 5 | # svntrac is free software; you can redistribute it and/or
|
|---|
| 6 | # modify it under the terms of the GNU General Public License as
|
|---|
| 7 | # published by the Free Software Foundation; either version 2 of the
|
|---|
| 8 | # License, or (at your option) any later version.
|
|---|
| 9 | #
|
|---|
| 10 | # svntrac is distributed in the hope that it will be useful,
|
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | # General Public License for more details.
|
|---|
| 14 | #
|
|---|
| 15 | # You should have received a copy of the GNU General Public License
|
|---|
| 16 | # along with this program; if not, write to the Free Software
|
|---|
| 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 18 | #
|
|---|
| 19 | # Author: Jonas Borgström <jonas@xyche.com>
|
|---|
| 20 |
|
|---|
| 21 | import os
|
|---|
| 22 | import sys
|
|---|
| 23 | import cgi
|
|---|
| 24 | import warnings
|
|---|
| 25 | from svn import util, repos
|
|---|
| 26 |
|
|---|
| 27 | warnings.filterwarnings('ignore', 'DB-API extension cursor.next() used')
|
|---|
| 28 |
|
|---|
| 29 | import db
|
|---|
| 30 | from auth import verify_authentication
|
|---|
| 31 | from perm import cache_permissions, PermissionError
|
|---|
| 32 |
|
|---|
| 33 | def load_config():
|
|---|
| 34 | import ConfigParser
|
|---|
| 35 | config = ConfigParser.ConfigParser()
|
|---|
| 36 | config.read('/home/jonas/src/svntrac/svntrac.conf')
|
|---|
| 37 | return config
|
|---|
| 38 |
|
|---|
| 39 | modules = {
|
|---|
| 40 | # name module class need_db need_svn
|
|---|
| 41 | 'log' : ('Log', 'Log', 1),
|
|---|
| 42 | 'file' : ('File', 'File', 1),
|
|---|
| 43 | 'menu' : ('Menu', 'Menu', 0),
|
|---|
| 44 | 'wiki' : ('Wiki', 'Wiki', 0),
|
|---|
| 45 | 'report' : ('Report', 'Report', 0),
|
|---|
| 46 | 'ticket' : ('Ticket', 'Ticket', 0),
|
|---|
| 47 | 'browser' : ('Browser', 'Browser', 1),
|
|---|
| 48 | 'timeline' : ('Timeline', 'Timeline', 1),
|
|---|
| 49 | 'changeset' : ('Changeset', 'Changeset', 1),
|
|---|
| 50 | 'newticket' : ('Ticket', 'Newticket', 0),
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | def main():
|
|---|
| 54 | mode = 'menu' #default module
|
|---|
| 55 | config = load_config()
|
|---|
| 56 |
|
|---|
| 57 | pool = util.svn_pool_create (None)
|
|---|
| 58 |
|
|---|
| 59 | _args = cgi.FieldStorage()
|
|---|
| 60 | args = {}
|
|---|
| 61 | for x in _args.keys():
|
|---|
| 62 | args[x] = _args[x].value
|
|---|
| 63 |
|
|---|
| 64 | if args.has_key('mode'):
|
|---|
| 65 | mode = args['mode']
|
|---|
| 66 |
|
|---|
| 67 | module_name, constructor_name, need_svn = modules[mode]
|
|---|
| 68 | module = __import__(module_name, globals(), locals(), [])
|
|---|
| 69 | constructor = getattr (module, constructor_name)
|
|---|
| 70 | module = constructor(config, args, pool)
|
|---|
| 71 |
|
|---|
| 72 | db.init (config)
|
|---|
| 73 | verify_authentication (args)
|
|---|
| 74 | cache_permissions ()
|
|---|
| 75 |
|
|---|
| 76 | if need_svn:
|
|---|
| 77 | repos_dir = config.get('general', 'repository_dir')
|
|---|
| 78 | rep = repos.svn_repos_open(repos_dir, pool)
|
|---|
| 79 | fs_ptr = repos.svn_repos_fs(rep)
|
|---|
| 80 | module.repos = rep
|
|---|
| 81 | module.fs_ptr = fs_ptr
|
|---|
| 82 | db.sync (rep, fs_ptr, pool)
|
|---|
| 83 |
|
|---|
| 84 | try:
|
|---|
| 85 | module.render ()
|
|---|
| 86 | module.apply_template ()
|
|---|
| 87 | except PermissionError, e:
|
|---|
| 88 | print 'Content-Type: text/plain\r\n\r\n',
|
|---|
| 89 | print 'page render failed:', e
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|