[SQL-CVS] r2329 - SQLObject/trunk/sqlobject/manager
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2007-02-20 15:51:28
|
Author: phd Date: 2007-02-20 08:51:16 -0700 (Tue, 20 Feb 2007) New Revision: 2329 Modified: SQLObject/trunk/sqlobject/manager/command.py Log: Fix N1 for the bug 1663785: ADD CONSTRAINT fails - do not apply constraints immediately - apply them after all tables has been created. Modified: SQLObject/trunk/sqlobject/manager/command.py =================================================================== --- SQLObject/trunk/sqlobject/manager/command.py 2007-02-20 15:31:55 UTC (rev 2328) +++ SQLObject/trunk/sqlobject/manager/command.py 2007-02-20 15:51:16 UTC (rev 2329) @@ -186,7 +186,7 @@ # This abstract base class return register(cls) - + def __init__(self, invoked_as, command_name, args, runner): self.invoked_as = invoked_as self.command_name = command_name @@ -394,7 +394,7 @@ continue classes = self.classes_from_module(module) all.extend(classes) - + os.path.walk(package_dir, find_classes_in_file, None) return all @@ -419,7 +419,7 @@ dir = conf['history_dir'] dir = dir.replace('$base', dist.location) self.options.output_dir = dir - + def config_from_egg(self, egg_spec, warn_no_sqlobject=True): import pkg_resources dist = pkg_resources.get_distribution(egg_spec) @@ -514,8 +514,8 @@ for constraint in constraints: if constraint: print constraint.strip() + ';\n' - + class CommandList(Command): name = 'list' @@ -580,14 +580,14 @@ if self.options.interactive: if self.ask('Create %s' % soClass.__name__): created += 1 - tableConstraints = soClass.createTable() + tableConstraints = soClass.createTable(applyConstraints=False) if tableConstraints: constraints[soClass._connection].append(tableConstraints) else: print 'Cancelled' else: created += 1 - tableConstraints = soClass.createTable() + tableConstraints = soClass.createTable(applyConstraints=False) if tableConstraints: constraints[soClass._connection].append(tableConstraints) for connection in constraints.keys(): @@ -600,8 +600,8 @@ if v >= 1: print '%i tables created (%i already exist)' % ( created, existing) - + class CommandDrop(Command): name = 'drop' @@ -802,7 +802,7 @@ 'database is currently at. Use the upgrade command to ' 'sync databases with code.' % SQLObjectVersionTable.sqlmeta.table) - + parser = standard_parser() parser.add_option('--output-dir', help="Base directory for recorded definitions", @@ -845,7 +845,7 @@ if self.options.force_db_version: self.command_force_db_version() return - + v = self.options.verbose sim = self.options.simulate classes = self.classes() @@ -988,7 +988,7 @@ def strip_comments(self, sql): lines = [l for l in sql.splitlines() if not l.strip().startswith('--')] - return '\n'.join(lines) + return '\n'.join(lines) def base_dir(self): base = self.options.output_dir @@ -1003,7 +1003,7 @@ def find_output_dir(self): today = time.strftime('%Y-%m-%d', time.localtime()) if self.options.version_name: - dir = os.path.join(self.base_dir(), today + '-' + + dir = os.path.join(self.base_dir(), today + '-' + self.options.version_name) if os.path.exists(dir): print ("Error, directory already exists: %s" @@ -1019,7 +1019,7 @@ extra = 'a' else: extra = chr(ord(extra)+1) - + def find_last_version(self): names = [] for fn in os.listdir(self.base_dir()): @@ -1116,8 +1116,8 @@ raise self.update_db(next_version, conn) print 'Done.' - + def current_version(self): conn = self.connection() if not conn.tableExists(SQLObjectVersionTable.sqlmeta.table): @@ -1177,8 +1177,8 @@ print 'No upgraders found in %s' % current_dir return None, None upgraders.sort() - return upgraders[-1] - + return upgraders[-1] + def update_sys_path(paths, verbose): if isinstance(paths, (str, unicode)): paths = [paths] |