Changeset 474
- Timestamp:
- 09/22/08 13:29:02 (5 years ago)
- File:
-
- 1 edited
-
trunk/plugins/oforgeplugin/oforge/api.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/oforgeplugin/oforge/api.py
r466 r474 5 5 import logging 6 6 import pkg_resources 7 import psycopg2 7 8 import re 8 9 import traceback … … 15 16 import trac.db_default 16 17 import trac.db 17 18 import psycopg219 18 20 19 class OForgeProjectCreationError(Exception): … … 170 169 # Setup vars 171 170 config = self.getconfig(name) 172 category = config.get('trac', 'category') 173 new_schema = name 174 new_user = name 171 new_schema = re.sub('\W+', '', name) 172 new_user = re.sub('\W+', '', name) 175 173 new_password = config.get('oforge','initial_db_password', 'secret') 176 174 project_desc = config.get('project','desc', name) 175 category = config.get('project', 'category') 176 project_display_name = config.get('project','name', name) 177 177 project_id = None 178 178 # Create the new schema/user … … 197 197 (id, name, display_name, type, active_state, start_date) 198 198 VALUES(%s, '%s', '%s', '%s', 'Open', '%s') 199 """%(project_id, name, project_d esc, category, datetime.datetime.now()))199 """%(project_id, name, project_display_name, category, datetime.datetime.now())) 200 200 master_db_cnx.commit() 201 201 except Exception, e: … … 204 204 205 205 src_db_cnx = self.getenv(name).get_db_cnx() 206 src_cursor = src_db_cnx.cursor()207 # Get list of tables excluding ones that shouldn't be copeied208 src_cursor.execute("""209 SELECT name210 FROM sqlite_master211 WHERE type = 'table' AND name != 'session'212 AND name != 'auth_cookie'213 ORDER BY name""")214 206 # Set trac database to new postgres schema 215 207 props = self.postgres_db_props() … … 229 221 EnvironmentSetup(new_env).environment_created() 230 222 new_env.upgrade(backup=False) 223 # Get list of tables excluding ones that shouldn't be copeied 224 target_db_cursor = target_db_cnx.cursor() 225 target_db_cursor.execute(""" 226 SELECT table_name 227 FROM information_schema.tables 228 WHERE table_schema = '%s' AND table_name != 'session' 229 AND table_name != 'auth_cookie'""", (new_schema,)) 231 230 # Copy tables 232 for table in map(lambda r: r[0], src_cursor.fetchall()):231 for table in map(lambda r: r[0], target_db_cursor.fetchall()): 233 232 self._copy_table(src_db_cnx, target_db_cnx, table) 234 233 # Commit all changes
Note: See TracChangeset
for help on using the changeset viewer.
