]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/app/php.py
Tabs to spaces.
[wizard.git] / wizard / app / php.py
index 5dbc5190869d3b8bd519579e89bb7accc595d67e..b617195949c62d38f53bd25e91a95b54203218e1 100644 (file)
@@ -7,6 +7,7 @@ Common data and functions for use in PHP applications.
 """
 
 import re
+import os
 
 from wizard import app, util
 
@@ -33,6 +34,15 @@ def re_define(var):
 def _make_filename_regex(var):
     return 'php.ini', re.compile('^(' + app.expand_re(var) + r'\s*=\s*)(.*)()$', re.M)
 
+def ini_replace_vars():
+    """
+    Replace ``WIZARD_TMPDIR`` and ``WIZARD_SESSIONNAME`` with with user-specific values.
+    """
+    text = open('php.ini', "r").read()
+    text = text.replace('WIZARD_TMPDIR', '/mit/%s/web_scripts_tmp' % os.environ['USER'])
+    text = text.replace('WIZARD_SESSIONNAME', '%s_SID' % os.environ['USER'])
+    open('php.ini', "w").write(text)
+
 seed = util.dictmap(_make_filename_regex, {
         'WIZARD_SESSIONNAME': 'session.name',
         'WIZARD_TMPDIR': ('upload_tmp_dir', 'session.save_path'),