]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/app/wordpress.py
Replace WIZARD variables in php.ini with user-specific values
[wizard.git] / wizard / app / wordpress.py
index ab80825bbb627e0aeb75af5f4dbb3f34952c2839..a068fb859ff03022057fc3632d36c4927463fb63 100644 (file)
@@ -24,45 +24,37 @@ seed = util.dictmap(make_filename_regex_define, {
     })
 
 class Application(app.Application):
+    database = "mysql"
     parametrized_files = ['wp-config.php'] + php.parametrized_files
     extractors = app.make_extractors(seed)
     extractors.update(php.extractors)
     substitutions = app.make_substitutions(seed)
     substitutions.update(php.substitutions)
-    install_schema = install.ArgSchema("mysql", "email", "title")
+    install_schema = install.ArgSchema("db", "email", "title")
     deprecated_keys = set(['WIZARD_SECRETKEY'])
+    random_keys = set(['WIZARD_SECRETKEY', 'WIZARD_AUTH_KEY', 'WIZARD_SECURE_AUTH_KEY', 'WIZARD_LOGGED_IN_KEY', 'WIZARD_NONCE_KEY'])
     def download(self, version):
         return "http://wordpress.org/wordpress-%s.tar.gz" % version
     def checkConfig(self, deployment):
         return os.path.isfile("wp-config.php")
-    def checkWeb(self, deployment, out=None):
-        page = deployment.fetch("")
-        if type(out) is list:
-            out.append(page)
-        return page.find("<html") != -1
+    def checkWeb(self, deployment):
+        # XXX: this sucks pretty hard
+        return self.checkWebPage(deployment, "", "<html")
     def detectVersion(self, deployment):
-        # XXX: Very duplicate code with MediaWiki; refactor
-        contents = deployment.read("wp-includes/version.php")
-        match = php.re_var("wp_version").search(contents)
-        if not match: return None
-        return distutils.version.LooseVersion(match.group(2)[1:-1])
+        return self.detectVersionFromFile("wp-includes/version.php", php.re_var("wp_version"))
     def prepareMerge(self, deployment):
         # This file shouldn't really be edited by users, but be careful: it's
         # stored as DOS and not as UNIX, so you'll get conflicts if you add this line:
         # resolve.fix_newlines("wp-config.php")
         pass
     def install(self, version, options):
-        # XXX: Hmm... we should figure out something about this
-        try:
-            os.unlink("wp-config.php")
-        except OSError:
-            pass
+        util.soft_unlink("wp-config.php")
 
         post_setup_config = {
-                'dbhost': options.mysql_host,
-                'uname': options.mysql_user,
-                'dbname': options.mysql_db,
-                'pwd': options.mysql_password,
+                'dbhost': options.dsn.host,
+                'uname': options.dsn.username,
+                'dbname': options.dsn.database,
+                'pwd': options.dsn.password,
                 'prefix': '',
                 'submit': 'Submit',
                 'step': '2',
@@ -84,11 +76,12 @@ class Application(app.Application):
             raise app.InstallFailure()
 
         # not sure what to do about this
-        meta = sql.mysql_connect(options)
+        meta = sql.connect(options.dsn)
         wp_options = meta.tables["wp_options"]
         wp_options.update().where(wp_options.c.option_name == 'siteurl').values(option_value=options.web_path).execute()
         wp_options.update().where(wp_options.c.option_name == 'home').values(option_value="http://%s%s" % (options.web_host, options.web_path)).execute() # XXX: what if missing leading slash; this should be put in a function
         # should also set the username and admin password
+        php.ini_replace_vars()
     def upgrade(self, d, version, options):
         result = d.fetch("wp-admin/upgrade.php?step=1")
         if "Upgrade Complete" not in result and "No Upgrade Required" not in result:
@@ -97,3 +90,20 @@ class Application(app.Application):
         app.backup_database(backup_dir, deployment)
     def restore(self, deployment, backup_dir, options):
         app.restore_database(backup_dir, deployment)
+    def remove(self, deployment, options):
+        app.remove_database(deployment)
+
+Application.resolutions = {
+'wp-config.php': [
+    ("""
+<<<<<<<
+
+/** WordPress absolute path to the Wordpress directory. */
+|||||||
+/** WordPress absolute path to the Wordpress directory. */
+=======
+/** Absolute path to the WordPress directory. */
+>>>>>>>
+""", [0])
+],
+}