Author: chrisz
Date: Sun Jul 22 18:19:30 2007
New Revision: 3343
URL: http://trac.turbogears.org/changeset/3343

Log:
tg-admin quickstart created a SQLObject model though --sqlalchemy option was 
given.

Modified:
   branches/1.0/turbogears/command/quickstart.py

Modified: branches/1.0/turbogears/command/quickstart.py
==============================================================================
--- branches/1.0/turbogears/command/quickstart.py       (original)
+++ branches/1.0/turbogears/command/quickstart.py       Sun Jul 22 18:19:30 2007
@@ -44,16 +44,16 @@
 
     required_templates = ["tgbase"]
     _template_dir = pkg_resources.resource_filename(
-                            "turbogears.qstemplates", 
+                            "turbogears.qstemplates",
                             "quickstart")
     summary = "web framework"
     use_cheetah = True
-   
+
 
 class TGBig(TGTemplate):
     required_templates = ["turbogears"]
     _template_dir = pkg_resources.resource_filename(
-                            "turbogears.qstemplates", 
+                            "turbogears.qstemplates",
                             "quickstartbig")
     summary = "For more complex projects"
 
@@ -84,7 +84,7 @@
 class TGWidgetTemplate(TGTemplate):
     required_templates = ["tgbase"]
     _template_dir = pkg_resources.resource_filename(
-                            "turbogears.qstemplates", 
+                            "turbogears.qstemplates",
                             "widget")
     summary = "TurboGears widget projects"
 
@@ -92,7 +92,7 @@
     "Implementation of quickstart."
 
     desc = "Create a new TurboGears project"
-    
+
     name = None
     package = None
     templates = "turbogears"
@@ -100,18 +100,18 @@
     sqlobject = True
     elixir = False
     identity = False
-    
+
     def __init__(self, version):
         parser = optparse.OptionParser(
                     usage="%prog quickstart [options] [project name]",
                     version="%prog " + version)
-        parser.add_option("-p", "--package", 
+        parser.add_option("-p", "--package",
             help="package name for the code",
             dest="package")
-        parser.add_option("--dry-run", 
+        parser.add_option("--dry-run",
             help="dry run (don't actually do anything)",
             action="store_true", dest="dry_run")
-        parser.add_option("-t", "--templates", 
+        parser.add_option("-t", "--templates",
             help="user specific templates",
             dest="templates", default = self.templates)
         parser.add_option("-s", "--sqlalchemy",
@@ -132,22 +132,21 @@
         if args:
             self.name = args[0]
         self.turbogearsversion = version
-    
+
     def run(self):
         "Quickstarts the new project."
-        if self.sqlobject:
-            self.sqlalchemy = False
-            self.elixir = False
-
-        if self.sqlalchemy:
-            self.elixir = False
 
         if self.elixir:
             self.sqlalchemy = True
+            self.sqlobject = False
+        elif self.sqlalchemy:
+            self.sqlobject = False
+        else:
+            self.sqlobject = True
 
         while not self.name:
             self.name = raw_input("Enter project name: ")
-        
+
         while not self.package:
             package = self.name.lower()
             package = beginning_letter.sub("", package)
@@ -161,7 +160,7 @@
             doidentity = raw_input("Do you need Identity "
                         "(usernames/passwords) in this project? [no] ")
             doidentity = doidentity.lower()
-            if not doidentity or doidentity.startswith('n'): 
+            if not doidentity or doidentity.startswith('n'):
                 self.identity="none"
                 break
             if doidentity.startswith("y"):
@@ -195,9 +194,8 @@
         if os.path.exists(self.name):
             print("A directory called '%s' already exists. Exiting."
                       % self.name)
-            return        
-            
-        
+            return
+
         command = create_distro.CreateDistroCommand("create")
         cmd_args = []
         for template in self.templates.split(" "):
@@ -211,18 +209,18 @@
             cmd_args.append("--simulate")
             cmd_args.append("-q")
         command.run(cmd_args)
-        
+
         if not self.dry_run:
             os.chdir(self.name)
             startscript = "start-%s.py" % self.package
             if os.path.exists(startscript):
                 oldmode = os.stat(startscript).st_mode
-                os.chmod(startscript, 
+                os.chmod(startscript,
                         oldmode | stat.S_IXUSR)
             sys.argv = ["setup.py", "egg_info"]
             import imp
             imp.load_module("setup", *imp.find_module("setup", ["."]))
-            
+
             # dirty hack to allow "empty" dirs
             for base,path,files in os.walk("./"):
                 for file in files:
@@ -231,17 +229,17 @@
 
 class update:
     "Implementation of update"
-    
+
     desc = "Update an existing turbogears project"
     need_project = True
-    
+
     name = None
     templates = "turbogears"
     identity = False
     sqlalchemy = False
     sqlobject = True
     elixir = False
-    
+
     def __init__(self, version):
         parser = optparse.OptionParser(usage="%prog quickstart [options]",
                                        version="%prog " + version)
@@ -269,16 +267,17 @@
         self.package = turbogears.util.get_package_name()
         turbogears.command.base.load_project_config()
 
-        if self.sqlobject:
-            self.sqlalchemy = False
-            self.elixir = False
-
         if not self.sqlalchemy:
             if turbogears.config.get('sqlalchemy.dburi'):
                 self.sqlalchemy = True
 
         if self.elixir:
             self.sqlalchemy = True
+            self.sqlobject = False
+        elif self.sqlalchemy:
+            self.sqlobject = False
+        else:
+            self.sqlobject = True
 
         if not self.identity:
             if turbogears.config.get('identity.on'):
@@ -295,7 +294,7 @@
         if not currentdir == self.name:
             print 'it looks like your project dir "%s" is named wrongly. 
Please rename it to "%s"' %(currentdir, self.name)
             return
-        
+
         command = create_distro.CreateDistroCommand("create")
         cmd_args = []
         cmd_args.append("-o../")
@@ -310,12 +309,12 @@
         startscript = "start-%s.py" % self.package
         if os.path.exists(startscript):
             oldmode = os.stat(startscript).st_mode
-            os.chmod(startscript, 
+            os.chmod(startscript,
                     oldmode | stat.S_IXUSR)
         sys.argv = ["setup.py", "egg_info"]
         import imp
         imp.load_module("setup", *imp.find_module("setup", ["."]))
-        
+
         # dirty hack to allow "empty" dirs
         for base,path,files in os.walk("./"):
             for file in files:

Reply via email to