[Zope-Checkins] CVS: Zope/lib/python/Products/PythonScripts - PythonScript.py:1.47

Andreas Jung andreas@andreas-jung.com
Sun, 6 Jul 2003 06:44:38 -0400


Update of /cvs-repository/Zope/lib/python/Products/PythonScripts
In directory cvs.zope.org:/tmp/cvs-serv8091/lib/python/Products/PythonScripts

Modified Files:
	PythonScript.py 
Log Message:
     - Collector #628: Applied patch to fix several textarea resize
       problems.


=== Zope/lib/python/Products/PythonScripts/PythonScript.py 1.46 => 1.47 ===
--- Zope/lib/python/Products/PythonScripts/PythonScript.py:1.46	Tue Jun 10 18:08:26 2003
+++ Zope/lib/python/Products/PythonScripts/PythonScript.py	Sun Jul  6 06:44:03 2003
@@ -164,20 +164,26 @@
                                                manage_tabs_message=message)
 
     def ZPythonScriptHTML_changePrefs(self, REQUEST, height=None, width=None,
-                                      dtpref_cols='50', dtpref_rows='20'):
+                                      dtpref_cols="100%", dtpref_rows="20"):
         """Change editing preferences."""
-        szchh = {'Taller': 1, 'Shorter': -1, None: 0}
-        szchw = {'Wider': 5, 'Narrower': -5, None: 0}
-        try: rows = int(height)
-        except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0))
-        try: cols = int(width)
-        except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0))
-        e = (DateTime('GMT') + 365).rfc822()
-        setc = REQUEST['RESPONSE'].setCookie
-        setc('dtpref_rows', str(rows), path='/', expires=e)
-        setc('dtpref_cols', str(cols), path='/', expires=e)
-        REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows})
-        return apply(self.manage_main, (self, REQUEST), REQUEST.form)
+        dr = {"Taller":5, "Shorter":-5}.get(height, 0)
+        dc = {"Wider":5, "Narrower":-5}.get(width, 0)
+        if isinstance(height, int): dtpref_rows = height
+        if isinstance(width, int) or \
+           isinstance(width, str) and width.endswith('%'):
+            dtpref_cols = width
+        rows = str(max(1, int(dtpref_rows) + dr))
+        cols = str(dtpref_cols)
+        if cols.endswith('%'):
+           cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
+        else:
+           cols = str(max(35, int(cols) + dc))
+        e = (DateTime("GMT") + 365).rfc822()
+        setCookie = REQUEST["RESPONSE"].setCookie
+        setCookie("dtpref_rows", rows, path='/', expires=e)
+        setCookie("dtpref_cols", cols, path='/', expires=e)
+        REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
+        return self.manage_main(self, REQUEST)
 
     def ZScriptHTML_tryParams(self):
         """Parameters to test the script with."""