id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
65,Trac 0.9b2 compatability,Ken McIvor <mcivor@iit.edu>,vgough,Here's a patch which makes your wonderful formula macro work under the latest version of trac:\r\n\r\n{{{\r\n--- formula.py-0.8      2005-10-07 15:05:20.000000000 -0500\r\n+++ formula.py-0.9      2005-10-21 18:49:42.023380773 -0500\r\n@@ -3_6 +3_9 @@\r\n by Valient Gough <vgough@pobox.com>\r\n\r\n Changes:\r\n+    2005-10-21  Ken McIvor <mcivor@iit.edu>:\r\n+        * Updated to support trac 0.9b2.\r\n+        * Improved the error messages for missing configuration elements.\r\n     2005-10-03:\r\n        * make image format selectable via 'image_format' configuration option\r\n          (defaults to 'jpg')\r\n@@ -107_32 +110_32 @@\r\n\r\n def render(hdf_ env_ texData_ density_ fleqnMode_ mathMode):\r\n     # gets paths from configuration\r\n-    tmpdir = env.get_config('latex'_ 'temp_dir')\r\n-    imagePath = env.get_config('latex'_ 'image_path')\r\n-    displayPath = env.get_config('latex'_ 'display_path')\r\n-    fleqnIndent = env.get_config('latex'_ 'fleqn_indent')\r\n-    latexPath = env.get_config('latex'_ 'latex_path')\r\n-    dvipsPath = env.get_config('latex'_ 'dvips_path')\r\n-    convertPath = env.get_config('latex'_ 'convert_path')\r\n-    texMag = env.get_config('latex'_ 'text_mag')\r\n-    imageFormat = env.get_config('latex'_ 'image_format')\r\n-\r\n-    if not tmpdir or not imagePath or not displayPath:\r\n-       return "<b>Error: missing configuration settings in 'latex' macro</b><br>"\r\n-\r\n-    # set defaults\r\n-    if not fleqnIndent:\r\n-        fleqnIndent = '5%'\r\n-    if not latexPath:\r\n-       latexPath = 'latex'\r\n-    if not dvipsPath:\r\n-       dvipsPath = 'dvips'\r\n-    if not convertPath:\r\n-       convertPath = 'convert'\r\n-    if not texMag:\r\n-       texMag = 1000 # I'm told this is latex's default value\r\n-    if not imageFormat:\r\n-       imageFormat = 'jpg'\r\n+    cfg = env.config\r\n+    tmpdir = cfg.get('latex'_ 'temp_dir')\r\n+    imagePath = cfg.get('latex'_ 'image_path')\r\n+    displayPath = cfg.get('latex'_ 'display_path')\r\n+    fleqnIndent = cfg.get('latex'_ 'fleqn_indent'_ '5%')\r\n+    latexPath = cfg.get('latex'_ 'latex_path'_ 'latex')\r\n+    dvipsPath = cfg.get('latex'_ 'dvips_path'_ 'dvips')\r\n+    convertPath = cfg.get('latex'_ 'convert_path'_ 'convert')\r\n+    texMag = cfg.get('latex'_ 'text_mag'_ 1000)\r\n+    imageFormat = cfg.get('latex'_ 'image_format'_ 'jpg')\r\n+\r\n+\r\n+    def make_cfg_error(element):\r\n+        msg = """\\\r\n+<div class="system-message">\r\n+ <strong>Error: the <code>formula</code> macro requires the setting <code>%s</code> in the configuration section <code>latex</code></strong>\r\n+</div>\r\n+"""\r\n+        return msg % element\r\n+\r\n+    if not tmpdir:\r\n+        return make_cfg_error('temp_dir')\r\n+    elif not imagePath:\r\n+        return make_cfg_error('image_path')\r\n+    elif not displayPath:\r\n+        return make_cfg_error('display_path')\r\n\r\n     path = tmpdir # + hdf.getValue("project.name.encoded"_ "default")\r\n     # create temporary directory if necessary\r\n@@ -219_6 +222_8 @@\r\n\r\n # arguments start with "#" on the beginning of a line\r\n def execute(hdf_ text_ env):\r\n+    cfg = env.config\r\n+\r\n     # TODO: unescape all html escape codes\r\n     text = text.replace("&amp;"_ "&")\r\n\r\n@@ -226_7 +231_7 @@\r\n     density = 100\r\n     mathMode = 1    # default to using display-math mode for LaTeX processing\r\n     displayMode = 0 # default to generating inline formula\r\n-    fleqnMode   = env.get_config('latex'_ 'fleqn')\r\n+    fleqnMode   = cfg.get('latex'_ 'fleqn')\r\n     centerImage = 0\r\n     indentImage = 0\r\n     indentClass = ""\r\n}}},enhancement,closed,normal,LatexFormulaMacro,normal,wontfix,patch,,0.8
