]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/app/__init__.py
Handle Wordpress random keys correctly on install and upgrade.
[wizard.git] / wizard / app / __init__.py
index f4b53a32dc2a02ce1c6926b5af31806264b8f146..a3664dba694ec340bd6334185875eb899e178cfa 100644 (file)
@@ -41,7 +41,6 @@ import logging
 import shutil
 import sqlalchemy
 import sqlalchemy.exc
-import random
 import string
 import urlparse
 import tempfile
@@ -115,6 +114,9 @@ class Application(object):
     deprecated_keys = set()
     #: Keys that we can simply generate random strings for if they're missing
     random_keys = set()
+    #: Values that are not sufficiently random for a random key.  This can
+    #: include default values for a random configuration option,
+    random_blacklist = set()
     #: Dictionary of variable names to extractor functions.  These functions
     #: take a :class:`wizard.deploy.Deployment` as an argument and return the value of
     #: the variable, or ``None`` if it could not be found.
@@ -173,8 +175,8 @@ class Application(object):
             result[k] = extractor(deployment)
         # XXX: ugh... we have to do quoting
         for k in self.random_keys:
-            if result[k] is None:
-                result[k] = "'%s'" % ''.join(random.choice(string.letters + string.digits) for i in xrange(30))
+            if result[k] is None or result[k] in self.random_blacklist:
+                result[k] = "'%s'" % util.random_key()
         return result
     def dsn(self, deployment):
         """
@@ -259,6 +261,9 @@ class Application(object):
         :attr:`parametrized_files` and a simple search and replace on those
         files.
         """
+        # deployment is not used in this implementation, but note that
+        # we do have the invariant the current directory matches
+        # deployment's directory
         variables = ref_deployment.extract()
         for file in self.parametrized_files:
             try: