]> scripts.mit.edu Git - wizard.git/commitdiff
Untested alternative support for web stubs.
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 4 May 2010 05:42:59 +0000 (01:42 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 4 May 2010 05:42:59 +0000 (01:42 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py
wizard/command/install.py
wizard/install/__init__.py

index 87c7b93dabab5fd11c54e8ffe27b11361eb9e608..4cfd54daaa85c550989c2d1b10226ab306a7d8de 100644 (file)
@@ -141,6 +141,8 @@ class Application(object):
     #: :class:`wizard.deploy.Deployment`; the value here is merely the preferred
     #: value.
     database = None
+    #: Indicates whether or not a web stub is necessary.
+    needs_web_stub = False
     def __init__(self, name):
         self.name = name
         self.versions = {}
index b398265dbdc52d305ffdb161b4f3c9d1f70d5b8c..e5d14656b9c874b2e3f81010122dbce5bf7e7f40 100644 (file)
@@ -12,6 +12,7 @@ def main(argv, baton):
 
     appstr = args[0]
     dir = os.path.abspath(args[1])
+    web_stub_path = old_options.web_stub_path
 
     if not old_options.retry and not old_options.help and os.path.exists(dir) and os.listdir(dir):
         raise DirectoryExistsError
@@ -19,9 +20,12 @@ def main(argv, baton):
     appname, _, version = appstr.partition('-')
     application = app.getApplication(appname)
 
+    if application.needs_web_stub and web_stub_path is None:
+        raise NeedsWebStubError
+
     # get configuration
     schema = application.install_schema
-    schema.commit(application, dir)
+    schema.commit(application, dir, web_stub_path)
     options = None
     opthandler = installopt.Controller(dir, schema)
     parser = command.WizardOptionParser("""usage: %%prog install %s DIR [ -- SETUPARGS ]
@@ -49,7 +53,11 @@ Autoinstalls the application %s in the directory DIR.""" % (appname, appname))
         if not old_options.retry and version and version != "head-scripts": # for ease in testing
             shell.call("git", "reset", "-q", "--hard", appstr)
         input.infobox("Installing...")
-        application.install(distutils.version.LooseVersion(version), options)
+        v = distutils.version.LooseVersion(version)
+        if application.needs_web_stub:
+            application.install(v, options, web_stub_path)
+        else:
+            application.install(v, options)
         if not old_options.no_commit:
             git.commit_configure()
     if not hasattr(options, "web_inferred"):
@@ -80,6 +88,9 @@ are required SETUPARGS if you want to run this non-interactively
 depending on what directory you are installing to.)"""
     parser = command.WizardOptionParser(usage, store_help=True)
     configure_parser(parser, baton)
+    parser.add_option("--web-stub-path", dest="web_stub_path",
+            default=None, help="Used on certain installations for indicating"
+            "where to place stub files for a web path.")
     options, args = parser.parse_all(argv)
     if options.help:
         if len(args) == 0:
@@ -95,3 +106,7 @@ depending on what directory you are installing to.)"""
 class DirectoryExistsError(wizard.Error):
     def __str__(self):
         return "Directory already exists and is not empty"
+
+class NeedsWebStubError(wizard.Error):
+    def __str__(self):
+        return "You need to specify a web stub directory for this application"
index 11b4599a4425c2d1b304893dd6fca3e6c39479dc..29c6f2127dfadc04ee5b6e775579b33c8482f4fd 100644 (file)
@@ -117,6 +117,8 @@ class ScriptsWebStrategy(Strategy):
         self.dir = dir
     def prepare(self):
         """Uses :func:`wizard.scripts.get_web_host_and_path`."""
+        if self.dir is None:
+            raise StrategyFailed
         self._url = scripts.fill_url(self.dir, None)
         if not self._url:
             raise StrategyFailed
@@ -223,17 +225,6 @@ class WebArgSet(ArgSet):
                 Arg("web_path", type="PATH", help="Relative path to your application root"),
                 ]
 
-class WebStubArgSet(ArgSet):
-    """
-    Common arguments for any application that has an extra folder
-    necessary to place "stub" code for an application, i.e. a
-    FastCGI script.  Most Python applications will require this.
-    """
-    def __init__(self):
-        self.args = [
-                Arg("web_stub_path", type="PATH", help="Absolute path to the directory containing the web stub"),
-                ]
-
 class DbArgSet(ArgSet):
     """Common arguments for applications that use a database."""
     def __init__(self):
@@ -272,7 +263,6 @@ def preloads():
     """
     return {
             'web': WebArgSet(),
-            'webstub': WebStubArgSet(),
             'db': DbArgSet(),
             'admin': AdminArgSet(),
             'email': EmailArgSet(),
@@ -285,7 +275,6 @@ class ArgSchema(object):
 
     Valid identifiers for subclasses of :class:`ArgSet` are:
 
-    * ``webstub``, which populates ``web_stub_path``.
     * ``db``, which populates the option ``dsn``, which is a SQLAlchemy
       database source name, with properties for ``drivername``,
       ``username``, ``password``, ``host``, ``port``, ``database`` and
@@ -322,7 +311,7 @@ class ArgSchema(object):
     def add(self, arg):
         """Adds an argument to our schema."""
         self.args[arg.name] = arg
-    def commit(self, application, dir):
+    def commit(self, application, dir, web_stub_path):
         """Populates :attr:`strategies` and :attr:`provides`"""
         self.strategies = []
         self.provides = set()
@@ -330,6 +319,7 @@ class ArgSchema(object):
         raw_strategies = [
                 EnvironmentStrategy(self),
                 ScriptsWebStrategy(dir),
+                ScriptsWebStrategy(web_stub_path),
                 ScriptsMysqlStrategy(application, dir),
                 ScriptsEmailStrategy(),
                 ]