PostgresqlPatch: pgsql_patch_12.diff
| File pgsql_patch_12.diff, 54.5 kB (added by brad <brad@dsource.org>, 4 years ago) |
|---|
-
scripts/trac-admin
old new 27 27 import time 28 28 import cmd 29 29 import shlex 30 import sqlite31 30 import StringIO 31 import traceback 32 32 33 33 from trac import perm 34 34 from trac import util … … 96 96 return 0 97 97 return 1 98 98 99 def env_create(self ):99 def env_create(self, db_str): 100 100 try: 101 self.__env = trac.Environment.Environment (self.envname, create=1)101 self.__env = trac.Environment.Environment (self.envname, 1, db_str) 102 102 return self.__env 103 103 except Exception, e: 104 104 print 'Failed to create environment.', e 105 print traceback.print_exc() 105 106 sys.exit(1) 106 107 107 108 def db_open(self): … … 115 116 116 117 def db_execsql (self, sql, cursor=None): 117 118 data = [] 119 row = None 118 120 if not cursor: 119 121 cnx=self.db_open() 120 122 cursor = cnx.cursor() … … 122 124 cnx = None 123 125 cursor.execute(sql) 124 126 while 1: 125 row = cursor.fetchone() 127 try: 128 row = cursor.fetchone() 129 except: 130 pass 126 131 if row == None: 127 132 break 128 133 data.append(row) … … 455 460 456 461 ## Initenv 457 462 _help_initenv = [('initenv', 'Create and initialize a new environment interactively'), 458 ('initenv <projectname> <repospath> <templatepath> ',463 ('initenv <projectname> <repospath> <templatepath> <dbms> [dbms options]', 459 464 'Create and initialize a new environment from arguments')] 460 465 461 466 def do_initdb(self, line): … … 488 493 dt = trac.siteconfig.__default_templates_dir__ 489 494 prompt = 'Templates directory [%s]> ' % dt 490 495 returnvals.append(raw_input(prompt) or dt) 496 print 497 print " Please enter the database in which you wish to store Trac data." 498 print " Default is 'sqlite', but others are supported:" 499 print " 'sqlite' - SQLite http://www.sqlite.org" 500 print " 'pypgsql' - PostgreSQL http://www.postgresql.org" 501 print 502 ddb = "sqlite" 503 prompt = 'database system [%s]> ' % ddb 504 dbms = raw_input(prompt) or ddb 505 returnvals.append(dbms) 506 507 # PostgreSQL - additional questions 508 if dbms == "pypgsql": 509 print 510 print " Please enter the host of your PostgreSQL database." 511 print " Default is 'localhost'" 512 print 513 host = "localhost" 514 prompt = "PostgreSQL host [%s]> " % host 515 returnvals.append(raw_input(prompt) or host) 516 517 print 518 print " Please enter the port of your PostgreSQL database." 519 print " Default is '5432'" 520 print 521 port = "5432" 522 prompt = "PostgreSQL port [%s]> " % port 523 returnvals.append(raw_input(prompt) or port) 524 525 print 526 print " Please enter the name of your PostgreSQL database." 527 print " Default is 'trac'" 528 print " Note: This database should not exist, as trac-admin will" \ 529 " attempt to create it." 530 print 531 name = "trac" 532 prompt = "PostgreSQL database [%s]> " % name 533 returnvals.append(raw_input(prompt) or name) 534 535 print 536 print " Please enter the user of your PostgreSQL database." 537 print " Default is 'trac'" 538 print 539 user = "trac" 540 prompt = "PostgreSQL user [%s]> " % user 541 returnvals.append(raw_input(prompt) or user) 542 543 print 544 print " Please enter the password of your PostgreSQL database." 545 print " Default is 'trac'" 546 print 547 password = "trac" 548 prompt = "PostgreSQL password [%s]> " % password 549 returnvals.append(raw_input(prompt) or password) 550 491 551 return returnvals 492 552 493 553 def do_initenv(self, line): … … 498 558 project_name = None 499 559 repository_dir = None 500 560 templates_dir = None 561 db_str = None 501 562 if len(arg) == 1: 502 563 returnvals = self.get_initenv_args() 503 564 project_name = returnvals[0] 504 565 repository_dir = returnvals[1] 505 566 templates_dir = returnvals[2] 506 elif len(arg)!= 3: 567 db_str = returnvals[3] 568 elif len(arg) < 4: 507 569 print 'Wrong number of arguments to initenv %d' % len(arg) 508 570 return 509 571 else: 510 572 project_name = arg[0] 511 573 repository_dir = arg[1] 512 574 templates_dir = arg[2] 575 db_str = arg[3] 576 577 # sqlite-specific stuff 578 if db_str.lower() == "sqlite": 579 db_str = 'sqlite:db/trac.db' 580 581 # postgres-specific stuff 582 if db_str.lower() == "pypgsql": 583 if len(arg) == 1: 584 host = returnvals[4] 585 port = returnvals[5] 586 database = returnvals[6] 587 user = returnvals[7] 588 password = returnvals[8] 589 elif len(arg) != 9: 590 print 'Wrong number of arguments to initenv %d' % len(arg) 591 print 'For PostgreSQL (after pypgsql): <host> <port> <database>' \ 592 ' <user> <password>' 593 return 594 else: 595 host = arg[4] 596 port = arg[5] 597 database = arg[6] 598 user = arg[7] 599 password = arg[8] 600 db_str = "pypgsql:host='%s:%s',database='%s',user='%s'," \ 601 "password='%s'" \ 602 % (host, port, database, user, password) 603 createdb_str = "createdb --host=%s --port=%s --owner=%s " \ 604 "--username=%s %s\n" \ 605 % (host, port, user, user, database) 606 print createdb_str 607 try: 608 # TODO: this is not cross-platform. 609 # for Windows, look at win32pipe.popen() 610 os.popen(createdb_str) 611 except Exception, e: 612 print "Error creating PostgreSQL database: %s" % e 613 print "command: %s" % createdb_str 614 513 615 from svn import util, repos, core 514 616 core.apr_initialize() 515 617 pool = core.svn_pool_create(None) … … 528 630 return 529 631 try: 530 632 print 'Creating and Initializing Project' 531 self.env_create() 633 634 # create db 635 self.env_create(db_str) 532 636 cnx = self.__env.get_db_cnx() 533 637 print ' Inserting default data' 534 638 self.__env.insert_default_data() … … 541 645 print ' project.name' 542 646 self.__env.set_config('project', 'name', project_name) 543 647 self.__env.save_config() 648 544 649 # Add a few default wiki pages 545 650 print ' Installing wiki pages' 546 651 cursor = cnx.cursor() … … 550 655 sync.sync(cnx, rep, fs_ptr, pool) 551 656 except Exception, e: 552 657 print 'Failed to initialize database.', e 658 print traceback.print_exc() 553 659 sys.exit(2) 554 660 555 661 … … 671 777 self.do_help ('wiki') 672 778 except Exception, e: 673 779 print 'Wiki %s failed:' % arg[0], e 780 print traceback.print_exc() 781 674 782 675 783 def _do_wiki_list(self): 676 784 data = self.db_execsql('SELECT name,max(version),time' -
setup.py
old new 199 199 author_email="info@edgewall.com", 200 200 license=LICENSE, 201 201 url=URL, 202 packages=['trac', 'trac.web', 'trac.upgrades', 'trac.wikimacros', 'trac.mimeviewers'], 202 packages=['trac', 'trac.dbms', 'trac.web', 'trac.upgrades', 203 'trac.wikimacros', 'trac.mimeviewers'], 203 204 data_files=[(_p('share/trac/templates'), glob('templates/*')), 204 205 (_p('share/trac/htdocs'), glob(_p('htdocs/*.*')) + [_p('htdocs/README')]), 205 206 (_p('share/trac/htdocs/css'), glob(_p('htdocs/css/*'))), -
trac/db_default.py
old new 37 37 ## Default data 38 38 ## 39 39 40 schema = """ 41 CREATE TABLE revision ( 42 rev integer PRIMARY KEY, 43 time integer, 44 author text, 45 message text 46 ); 47 CREATE TABLE node_change ( 48 rev integer, 49 name text, 50 change char(1), 51 UNIQUE(rev, name, change) 52 ); 53 CREATE TABLE auth_cookie ( 54 cookie text, 55 name text, 56 ipnr text, 57 time integer, 58 UNIQUE(cookie, name, ipnr) 59 ); 60 CREATE TABLE enum ( 61 type text, 62 name text, 63 value text, 64 UNIQUE(name,type) 65 ); 66 CREATE TABLE system ( 67 name text PRIMARY KEY, 68 value text, 69 UNIQUE(name) 70 ); 71 CREATE TABLE ticket ( 72 id integer PRIMARY KEY, 73 time integer, -- the time it was created 74 changetime integer, 75 component text, 76 severity text, 77 priority text, 78 owner text, -- who is this ticket assigned to 79 reporter text, 80 cc text, -- email addresses to notify 81 url text, -- url related to this ticket 82 version text, -- 83 milestone text, -- 84 status text, 85 resolution text, 86 summary text, -- one-line summary 87 description text, -- problem description (long) 88 keywords text 89 ); 90 CREATE TABLE ticket_change ( 91 ticket integer, 92 time integer, 93 author text, 94 field text, 95 oldvalue text, 96 newvalue text, 97 UNIQUE(ticket, time, field) 98 ); 99 CREATE TABLE ticket_custom ( 100 ticket integer, 101 name text, 102 value text, 103 UNIQUE(ticket,name) 104 ); 105 CREATE TABLE report ( 106 id integer PRIMARY KEY, 107 author text, 108 title text, 109 sql text, 110 description text 111 ); 112 CREATE TABLE permission ( 113 username text, -- 114 action text, -- allowable activity 115 UNIQUE(username,action) 116 ); 117 CREATE TABLE component ( 118 name text PRIMARY KEY, 119 owner text 120 ); 121 CREATE TABLE milestone ( 122 name text PRIMARY KEY, 123 due integer, 124 completed integer, 125 description text 126 ); 127 CREATE TABLE version ( 128 name text PRIMARY KEY, 129 time integer 130 ); 131 CREATE TABLE wiki ( 132 name text, 133 version integer, 134 time integer, 135 author text, 136 ipnr text, 137 text text, 138 comment text, 139 readonly integer, 140 UNIQUE(name,version) 141 ); 142 CREATE TABLE attachment ( 143 type text, 144 id text, 145 filename text, 146 size integer, 147 time integer, 148 description text, 149 author text, 150 ipnr text, 151 UNIQUE(type,id,filename) 152 ); 40 schema = ( 41 ('revision', ( 42 ('rev', 'auto', '', 'u'), 43 ('time', 'int', '', ''), 44 ('author', 'text', '', ''), 45 ('message', 'text', '', ''))), 46 ('node_change', ( 47 ('rev', 'int', '', 'u'), 48 ('name', 'text', '', 'u'), 49 ('change', 'text', '1', 'u'))), 50 ('auth_cookie', ( 51 ('cookie', 'text', '', 'u'), 52 ('name', 'text', '', 'u'), 53 ('ipnr', 'text', '', 'u'), 54 ('time', 'int', '', ''))), 55 ('enum', ( 56 ('type', 'text', '', 'u'), 57 ('name', 'text', '', 'u'), 58 ('value', 'text', '', ''))), 59 ('system', ( 60 ('name', 'text', '', 'u'), 61 ('value', 'text', '', ''))), 62 ('ticket', ( 63 ('id', 'auto', '', 'u'), 64 ('time', 'int', '', ''), 65 ('changetime', 'int', '', ''), 66 ('component', 'text', '', ''), 67 ('severity', 'text', '', ''), 68 ('priority', 'text', '', ''), 69 ('owner', 'text', '', ''), 70 ('reporter', 'text', '', ''), 71 ('cc', 'text', '', ''), 72 ('url', 'text', '', ''), 73 ('version', 'text', '', ''), 74 ('milestone', 'text', '', ''), 75 ('status', 'text', '', ''), 76 ('resolution', 'text', '', ''), 77 ('summary', 'text', '', ''), 78 ('description', 'text', '', ''), 79 ('keywords', 'text', '', ''))), 80 ('ticket_change', ( 81 ('ticket', 'int', '', 'u'), 82 ('time', 'int', '', 'u'), 83 ('author', 'text', '', ''), 84 ('field', 'text', '', 'u'), 85 ('oldvalue', 'text', '', ''), 86 ('newvalue', 'text', '', ''))), 87 ('ticket_custom', ( 88 ('ticket', 'int', '', 'u'), 89 ('name', 'text', '', 'u'), 90 ('value', 'text', '', ''))), 91 ('report', ( 92 ('id', 'auto', '', 'u'), 93 ('author', 'text', '', ''), 94 ('title', 'text', '', ''), 95 ('sql', 'text', '', ''), 96 ('description', 'text', '', ''))), 97 ('permission', ( 98 ('username', 'text', '', 'u'), 99 ('action', 'text', '', 'u'))), 100 ('component', ( 101 ('name', 'text', '', 'u'), 102 ('owner', 'text', '', ''))), 103 ('milestone', ( 104 ('name', 'text', '', 'u'), 105 ('due', 'int', '', ''), 106 ('completed', 'int', '', ''), 107 ('description', 'text', '', ''))), 108 ('version', ( 109 ('name', 'text', '', 'u'), 110 ('time', 'int', '', ''))), 111 ('wiki', ( 112 ('name', 'text', '', 'u'), 113 ('version', 'int', '', 'u'), 114 ('time', 'int', '', ''), 115 ('author', 'text', '', ''), 116 ('ipnr', 'text', '', ''), 117 ('text', 'text', '', ''), 118 ('comment', 'text', '', ''), 119 ('readonly', 'int', '', ''))), 120 ('attachment', ( 121 ('type', 'text', '', 'u'), 122 ('id', 'text', '', 'u'), 123 ('filename', 'text', '', 'u'), 124 ('size', 'int', '', ''), 125 ('time', 'int', '', ''), 126 ('description', 'text', '', ''), 127 ('author', 'text', '', ''), 128 ('ipnr', 'text', '', ''))), 129 ('session', ( 130 ('sid', 'text', '', 'u'), 131 ('username', 'text', '', ''), 132 ('var_name', 'text', '', 'u'), 133 ('var_value', 'text', '', '')))) 134 135 # TODO: do we need these, or will the pk's and u's above do? 136 #CREATE INDEX node_change_idx ON node_change(rev); 137 #CREATE INDEX ticket_change_idx ON ticket_change(ticket, time); 138 #CREATE INDEX wiki_idx ON wiki(name,version); 139 #CREATE INDEX session_idx ON session(sid,var_name); 140 #""" 153 141 154 CREATE TABLE session (155 sid text,156 username text,157 var_name text,158 var_value text,159 UNIQUE(sid,var_name)160 );161 142 162 CREATE INDEX node_change_idx ON node_change(rev);163 CREATE INDEX ticket_change_idx ON ticket_change(ticket, time);164 CREATE INDEX wiki_idx ON wiki(name,version);165 CREATE INDEX session_idx ON session(sid,var_name);166 """167 168 143 ## 169 144 ## Default Reports 170 145 ## … … 286 261 FROM ticket t,enum p 287 262 WHERE p.name=t.priority AND p.type='priority' 288 263 ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'), 289 (CASE status WHEN 'closed' THEN modifiedELSE (-1)*p.value END) DESC264 (CASE status WHEN 'closed' THEN changetime ELSE (-1)*p.value END) DESC 290 265 """), 291 266 #---------------------------------------------------------------------------- 292 267 ('My Tickets', -
trac/dbms/db_pypgsql.py
old new 1 # -*- coding: iso8859-1 -*- 2 # 3 # Copyright (C) 2005 Edgewall Software 4 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de> 5 # 6 # Trac is free software; you can redistribute it and/or 7 # modify it under the terms of the GNU General Public License as 8 # published by the Free Software Foundation; either version 2 of the 9 # License, or (at your option) any later version. 10 # 11 # Trac is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 # General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 # 20 # Author: Christopher Lenz <cmlenz@gmx.de> 21 22 import os 23 from pyPgSQL import PgSQL 24 import string 25 26 from trac import db_default 27 28 from trac.db import ConnectionWrapper 29 30 from trac.util import TracError 31 32 class PyPgSQLConnection(ConnectionWrapper): 33 """ 34 Connection wrapper for PostgreSQL using the PyPgSQL driver. 35 """ 36 37 __slots__ = ['cnx'] 38 39 def __init__(self, dbargs, env, create=0): 40 if create: 41 self.create_db(env.path, dbargs) 42 43 # TODO: check to see if db exists, or throw error (see sqlite module) 44 45 args = self.parse_args(dbargs) 46 47 cnx = PgSQL.connect("", **args) 48 ConnectionWrapper.__init__(self, cnx) 49 50 def get_last_id(self, table, field): 51 cursor = self.cursor() 52 sql = "SELECT %s FROM %s " \ 53 "WHERE %s = CURRVAL('%s_%s_seq')" \ 54 % (field, table, field, table, field) 55 cursor.execute(sql) 56 id = cursor.fetchone()[0] 57 cursor.close() 58 return id 59 60 def create_db(self, path, dbargs): 61 62 # TODO: make the database 63 # Are we able to do this without su - postgres ?? 64 # Should we move what's in trac-admin to here? Probably... 65 66 args = self.parse_args(dbargs) 67 68 # get a connection 69 cnx = PgSQL.connect("", **args) 70 71 # populate the default schema 72 schema = db_default.schema 73 sql = "" 74 75 for tables in schema: 76 table = tables[0] 77 fields = tables[1] 78 sql_fields = [] 79 unique = [] 80 sql += "CREATE TABLE %s (\n" % table 81 82 for field in fields: 83 name = field[0] 84 type = field[1] 85 size = field[2] 86 pk = field[3] 87 88 if type == 'auto': 89 type = 'serial' 90 91 if pk == 'u': 92 unique.append(name) 93 94 sql_fields.append(" %s %s" % (name, type)) 95 96 if len(unique): 97 sql_fields.append(" CONSTRAINT %s_pkey PRIMARY KEY(%s)" % 98 (table, ",".join(unique))) 99 sql += ",\n".join(sql_fields) 100 sql += "\n);\n\n" 101 102 cursor = cnx.cursor() 103 cursor.execute(sql) 104 cnx.commit() 105 106 cursor.close() 107 cnx.close() 108 109 def parse_args(self, dbargs): 110 """very crude code for parsing the arguments in connect_params""" 111 112 kargs = {} 113 args = dbargs.split(",") 114 115 for arg in args: 116 pair = arg.split("=") 117 name = pair[0] 118 value = pair[1].strip("'") 119 kargs[name] = value 120 121 return kargs 122 123 def get_search_fields(self): 124 return {'changeset' : 'cast(rev as text)', 125 'ticket' : 'cast(a.id as text)'} 126 127 -
trac/dbms/db_sqlite.py
old new 1 # -*- coding: iso8859-1 -*- 2 # 3 # Copyright (C) 2005 Edgewall Software 4 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de> 5 # 6 # Trac is free software; you can redistribute it and/or 7 # modify it under the terms of the GNU General Public License as 8 # published by the Free Software Foundation; either version 2 of the 9 # License, or (at your option) any later version. 10 # 11 # Trac is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 # General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 # 20 # Author: Christopher Lenz <cmlenz@gmx.de> 21 22 import os 23 import sqlite 24 import string 25 import traceback 26 27 from trac import db_default 28 29 from trac.db import ConnectionWrapper 30 31 from trac.util import TracError 32 33 class SQLiteConnection(ConnectionWrapper): 34 """ 35 Connection wrapper for SQLite. 36 """ 37 38 __slots__ = ['cnx'] 39 40 def __init__(self, dbpath, env, create=0, timeout=10000): 41 42 if create: 43 self.create_db(env.path, dbpath) 44 45 if dbpath != ':memory:': 46 if not os.access(dbpath, os.F_OK): 47 raise TracError, traceback.print_exc() 48 raise TracError, 'Database "%s" not found.' % dbpath 49 50 dbdir = os.path.dirname(dbpath) 51 if not os.access(dbpath, os.R_OK + os.W_OK) or \ 52 not os.access(dbdir, os.R_OK + os.W_OK): 53 raise TracError, 'The web server user requires read _and_ ' \ 54 'write permission to the database %s and ' \ 55 'the directory this file is located in.' \ 56 % dbpath 57 58 import sqlite 59 cnx = sqlite.connect(dbpath, timeout=timeout) 60 ConnectionWrapper.__init__(self, cnx) 61 62 def get_last_id(self, table, field): 63 return self.cnx.db.sqlite_last_insert_rowid() 64 65 def create_db(self, path, dbpath): 66 67 # make the directory to hold the database 68 os.mkdir(os.path.join(path, 'db')) 69 70 # create the database by getting a connection 71 cnx = sqlite.connect(dbpath, timeout=100) 72 73 # populate the default schema 74 schema = db_default.schema 75 sql = "" 76 77 for tables in schema: 78 table = tables[0] 79 fields = tables[1] 80 sql_fields = [] 81 unique = [] 82 sql += "CREATE TABLE %s (\n" % table 83 84 for field in fields: 85 name = field[0] 86 type = field[1] 87 size = field[2] 88 pk = field[3] 89 90 if type == 'auto': 91 type = 'INTEGER PRIMARY KEY' 92 93 if pk == 'u': 94 unique.append(name) 95 96 sql_fields.append(" %s %s" % (name, type)) 97 98 if len(unique): 99 sql_fields.append(" UNIQUE(%s)" % ",".join(unique)) 100 sql += ",\n".join(sql_fields) 101 sql += "\n);\n\n" 102 103 cursor = cnx.cursor() 104 cursor.execute(sql) 105 cnx.commit() 106 107 cursor.close() 108 cnx.close() 109 110 def get_search_fields(self): 111 return {'changeset' : 'rev', 112 'ticket' : 'a.id'} 113 -
trac/Search.py
old new 135 135 'Search Error') 136 136 137 137 cursor = self.db.cursor () 138 138 search_fields = self.db.get_search_fields() 139 139 140 q = [] 140 141 if changeset: 141 142 q.append("SELECT 1 as type, message AS title, message, author, " 142 "'' AS keywords, revAS data, time,0 AS ver "143 "'' AS keywords, %s AS data, time,0 AS ver " 143 144 "FROM revision WHERE %s OR %s" % 144 (self.query_to_sql(query, 'message'), 145 (search_fields['changeset'], 146 self.query_to_sql(query, 'message'), 145 147 self.query_to_sql(query, 'author'))) 146 148 if tickets: 147 149 q.append("SELECT DISTINCT 2 as type, a.summary AS title, " 148 150 "a.description AS message, a.reporter AS author, " 149 "a.keywords as keywords, a.idAS data, a.time as time, 0 AS ver "151 "a.keywords as keywords, %s AS data, a.time as time, 0 AS ver " 150 152 "FROM ticket a LEFT JOIN ticket_change b ON a.id = b.ticket " 151 153 "WHERE (b.field='comment' AND %s ) OR " 152 154 "%s OR %s OR %s OR %s OR %s" % 153 (self.query_to_sql(query, 'b.newvalue'), 155 (search_fields['ticket'], 156 self.query_to_sql(query, 'b.newvalue'), 154 157 self.query_to_sql(query, 'summary'), 155 158 self.query_to_sql(query, 'keywords'), 156 159 self.query_to_sql(query, 'description'), -
trac/Query.py
old new 154 154 sql.append("\nFROM ticket") 155 155 for k in [k for k in cols if k in custom_fields]: 156 156 sql.append("\n LEFT OUTER JOIN ticket_custom AS %s ON " \ 157 "(id=%s.ticket AND %s.name='%s') " % (k, k, k, k))157 "(id=%s.ticket AND %s.name='%s') tc" % (k, k, k, k)) 158 158 159 159 for col in [c for c in ['status', 'resolution', 'priority', 'severity'] 160 160 if c == self.order or c == self.group]: 161 161 sql.append("\n LEFT OUTER JOIN (SELECT name AS %s_name, " \ 162 162 "value AS %s_value " \ 163 "FROM enum WHERE type='%s') " \163 "FROM enum WHERE type='%s') e" \ 164 164 " ON %s_name=%s" % (col, col, col, col, col)) 165 165 for col in [c for c in ['milestone', 'version'] 166 166 if c == self.order or c == self.group]: 167 167 time_col = col == 'milestone' and 'due' or 'time' 168 168 sql.append("\n LEFT OUTER JOIN (SELECT name AS %s_name, " \ 169 "%s AS %s_time FROM %s) " \169 "%s AS %s_time FROM %s) a" \ 170 170 " ON %s_name=%s" % (col, time_col, col, col, col, col)) 171 171 172 172 def get_constraint_sql(name, value, mode, neg): -
trac/Report.py
old new 112 112 cursor = self.db.cursor() 113 113 cursor.execute("INSERT INTO report (title,sql,description) " 114 114 "VALUES (%s,%s,%s)", (title, sql, description)) 115 id = self.db.get_last_id( )115 id = self.db.get_last_id("report", "id") 116 116 self.db.commit() 117 117 req.redirect(self.env.href.report(id)) 118 118 -
trac/tests/tracadmin-tests.txt
old new 1 1 ===== test_help_ok ===== 2 trac-admin - The Trac Administration Console %(version)s2 trac-admin - The Trac Administration Console 0.8 3 3 4 4 Usage: trac-admin </path/to/projenv> [command [subcommand] [option ...]] 5 5 6 6 Invoking trac-admin without command starts interactive mode. 7 7 8 about -- Shows information about trac-admin 9 help -- Show documentation 10 initenv -- Create and initialize a new environment interactively 11 initenv <projectname> <repospath> <templatepath> -- Create and initialize a new environment from arguments 12 hotcopy <backupdir> -- Make a hot backup copy of an environment 13 resync -- Re-synchronize trac with the repository 14 upgrade -- Upgrade database to current version 15 wiki list -- List wiki pages 16 wiki remove <name> -- Remove wiki page 17 wiki export <page> [file] -- Export wiki page to file or stdout 18 wiki import <page> [file] -- Import wiki page from file or stdin 19 wiki dump <directory> -- Export all wiki pages to files named by title 20 wiki load <directory> -- Import all wiki pages from directory 21 wiki upgrade -- Upgrade default wiki pages to current version 22 permission list -- List permission rules 23 permission add <user> <action> [action] [...] -- Add a new permission rule 24 permission remove <user> <action> [action] [...] -- Remove permission rule 25 component list -- Show available components 26 component add <name> <owner> -- Add a new component 27 component rename <name> <newname> -- Rename a component 28 component remove <name> -- Remove/uninstall component 29 component chown <name> <owner> -- Change component ownership 30 priority list -- Show possible ticket priorities 31 priority add <value> -- Add a priority value option 32 priority change <value> <newvalue> -- Change a priority value 33 priority remove <value> -- Remove priority value 34 severity list -- Show possible ticket severities 35 severity add <value> -- Add a severity value option 36 severity change <value> <newvalue> -- Change a severity value 37 severity remove <value> -- Remove severity value 38 version list -- Show versions 39 version add <name> [time] -- Add version 40 version rename <name> <newname> -- Rename version 41 version time <name> <time> -- Set version date (Format: "%(date_format_hint)s" or "now") 42 version remove <name> -- Remove version 43 milestone list -- Show milestones 44 milestone add <name> [due] -- Add milestone 45 milestone rename <name> <newname> -- Rename milestone 46 milestone due <name> <due> -- Set milestone due date (Format: "%(date_format_hint)s" or "now") 47 milestone completed <name> <completed> -- Set milestone completed date (Format: "%(date_format_hint)s" or "now") 48 milestone remove <name> -- Remove milestone 8 about -- Shows information about trac-admin 9 help -- Show documentation 10 initenv -- Create and initialize a new environment interactively 11 initenv <projectname> <repospath> <templatepath> <dbms> [dbms options] -- Create and initialize a new environment from arguments 12 hotcopy <backupdir> -- Make a hot backup copy of an environment 13 resync -- Re-synchronize trac with the repository 14 upgrade -- Upgrade database to current version 15 wiki list -- List wiki pages 16 wiki export <page> [file] -- Export wiki page to file or stdout 17 wiki import <page> [file] -- Import wiki page from file or stdin 18 wiki dump <directory> -- Export all wiki pages to files named by title 19 wiki load <directory> -- Import all wiki pages from directory 20 wiki upgrade -- Upgrade default wiki pages to current version 21 permission list -- List permission rules 22 permission add <user> <action> [action] [...] -- Add a new permission rule 23 permission remove <user> <action> [action] [...] -- Remove permission rule 24 component list -- Show available components 25 component add <name> <owner> -- Add a new component 26 component rename <name> <newname> -- Rename a component 27 component remove <name> -- Remove/uninstall component 28 component chown <name> <owner> -- Change component ownership 29 priority list -- Show possible ticket priorities 30 priority add <value> -- Add a priority value option 31 priority change <value> <newvalue> -- Change a priority value 32 priority remove <value> -- Remove priority value 33 severity list -- Show possible ticket priorities 34 severity add <value> -- Add a severity value option 35 severity change <value> <newvalue> -- Change a severity value 36 severity remove <value> -- Remove severity value 37 version list -- Show versions 38 version add <name> [time] -- Add version 39 version rename <name> <newname> -- Rename version 40 version time <name> <time> -- Set version date (Format: "MM/DD/YY" or "now") 41 version remove <name> -- Remove version 42 milestone list -- Show milestones 43 milestone add <name> [due] -- Add milestone 44 milestone rename <name> <newname> -- Rename milestone 45 milestone due <name> <due> -- Set milestone due date (Format: "MM/DD/YY" or "now") 46 milestone completed <name> <completed> -- Set milestone completed date (Format: "MM/DD/YY" or "now") 47 milestone remove <name> -- Remove milestone 49 48 50 49 Visit the Trac Project at http://trac.edgewall.com/ 51 50 -
trac/tests/environment.py
old new 39 39 40 40 def test_config(self): 41 41 """Testing env.get/set_config""" 42 assert self.env.get_config('trac', 'database') == 'sqlite:db/trac.db' 42 # Any way to do this with multiple backends now supported? 43 # assert self.env.get_config('trac', 'database') == 'sqlite:db/trac.db' 43 44 self.env.set_config('foo', 'bar', 'baz') 44 45 self.env.save_config() 45 46 assert self.env.get_config('foo', 'bar') == 'baz' -
trac/tests/query.py
old new 45 45 self.assertEqual(sql, 46 46 """SELECT id,summary,status,owner,priority,milestone,component,time,changetime 47 47 FROM ticket 48 LEFT OUTER JOIN (SELECT name AS priority_name, value AS priority_value FROM enum WHERE type='priority') ON priority_name=priority48 LEFT OUTER JOIN (SELECT name AS priority_name, value AS priority_value FROM enum WHERE type='priority') e ON priority_name=priority 49 49 ORDER BY COALESCE(priority,'')='',priority_value,id""") 50 50
