1 2========= 3Changelog 4========= 5 61.3 7=== 8 9.. changelog:: 10 :version: 1.3.0 11 :released: Wed Nov 8 2023 12 13 .. change:: 14 :tags: change, installation 15 16 Mako 1.3.0 bumps the minimum Python version to 3.8, as 3.7 is EOL as of 17 2023-06-27. Python 3.12 is now supported explicitly. 18 191.2 20=== 21 22 23.. changelog:: 24 :version: 1.2.4 25 :released: Tue Nov 15 2022 26 27 .. change:: 28 :tags: bug, codegen 29 :tickets: 368 30 31 Fixed issue where unpacking nested tuples in a for loop using would raise a 32 "couldn't apply loop context" error if the loop context was used. The regex 33 used to match the for loop expression now allows the list of loop variables 34 to contain parenthesized sub-tuples. Pull request courtesy Matt Trescott. 35 36 37.. changelog:: 38 :version: 1.2.3 39 :released: Thu Sep 22 2022 40 41 .. change:: 42 :tags: bug, lexer 43 :tickets: 367 44 45 Fixed issue in lexer in the same category as that of :ticket:`366` where 46 the regexp used to match an end tag didn't correctly organize for matching 47 characters surrounded by whitespace, leading to high memory / interpreter 48 hang if a closing tag incorrectly had a large amount of unterminated space 49 in it. Credit to Sebastian Chnelik for locating the issue. 50 51 As Mako templates inherently render and directly invoke arbitrary Python 52 code from the template source, it is **never** appropriate to create 53 templates that contain untrusted input. 54 55.. changelog:: 56 :version: 1.2.2 57 :released: Mon Aug 29 2022 58 59 .. change:: 60 :tags: bug, lexer 61 :tickets: 366 62 63 Fixed issue in lexer where the regexp used to match tags would not 64 correctly interpret quoted sections individually. While this parsing issue 65 still produced the same expected tag structure later on, the mis-handling 66 of quoted sections was also subject to a regexp crash if a tag had a large 67 number of quotes within its quoted sections. Credit to Sebastian 68 Chnelik for locating the issue. 69 70 As Mako templates inherently render and directly invoke arbitrary Python 71 code from the template source, it is **never** appropriate to create 72 templates that contain untrusted input. 73 74.. changelog:: 75 :version: 1.2.1 76 :released: Thu Jun 30 2022 77 78 .. change:: 79 :tags: performance 80 :tickets: 361 81 82 Optimized some codepaths within the lexer/Python code generation process, 83 improving performance for generation of templates prior to their being 84 cached. Pull request courtesy Takuto Ikuta. 85 86 .. change:: 87 :tags: bug, tests 88 :tickets: 360 89 90 Various fixes to the test suite in the area of exception message rendering 91 to accommodate for variability in Python versions as well as Pygments. 92 93.. changelog:: 94 :version: 1.2.0 95 :released: Thu Mar 10 2022 96 97 .. change:: 98 :tags: changed, py3k 99 :tickets: 351 100 101 Corrected "universal wheel" directive in ``setup.cfg`` so that building a 102 wheel does not target Python 2. 103 104 .. change:: 105 :tags: changed, py3k 106 107 The ``bytestring_passthrough`` template argument is removed, as this 108 flag only applied to Python 2. 109 110 .. change:: 111 :tags: changed, py3k 112 113 With the removal of Python 2's ``cStringIO``, Mako now uses its own 114 internal ``FastEncodingBuffer`` exclusively. 115 116 .. change:: 117 :tags: changed, py3k 118 119 Removed ``disable_unicode`` flag, that's no longer used in Python 3. 120 121 .. change:: 122 :tags: changed 123 :tickets: 349 124 125 Refactored test utilities into ``mako.testing`` module. Removed 126 ``unittest.TestCase`` dependency in favor of ``pytest``. 127 128 .. change:: 129 :tags: changed, setup 130 131 Replaced the use of ``pkg_resources`` with the ``importlib`` library. 132 For Python < 3.8 the library ``importlib_metadata`` is used. 133 134 .. change:: 135 :tags: changed, py3k 136 137 Removed support for Python 2 and Python 3.6. Mako now requires Python >= 138 3.7. 139 140 .. change:: 141 :tags: bug, py3k 142 143 Mako now performs exception chaining using ``raise from``, correctly 144 identifying underlying exception conditions when it raises its own 145 exceptions. Pull request courtesy Ram Rachum. 146 1471.1 148=== 149 150.. changelog:: 151 :version: 1.1.6 152 :released: Wed Nov 17 2021 153 154 .. change:: 155 :tags: bug, lexer 156 :tickets: 346 157 :versions: 1.2.0, 1.1.6 158 159 Fixed issue where control statements on multi lines with a backslash would 160 not parse correctly if the template itself contained CR/LF pairs as on 161 Windows. Pull request courtesy Charles Pigott. 162 163 164.. changelog:: 165 :version: 1.1.5 166 :released: Fri Aug 20 2021 167 168 .. change:: 169 :tags: bug, tests 170 :tickets: 338 171 172 Fixed some issues with running the test suite which would be revealed by 173 running tests in random order. 174 175 176 177.. changelog:: 178 :version: 1.1.4 179 :released: Thu Jan 14 2021 180 181 .. change:: 182 :tags: bug, py3k 183 :tickets: 328 184 185 Fixed Python deprecation issues related to module importing, as well as 186 file access within the Lingua plugin, for deprecated APIs that began to 187 emit warnings under Python 3.10. Pull request courtesy Petr Viktorin. 188 189.. changelog:: 190 :version: 1.1.3 191 :released: Fri May 29 2020 192 193 .. change:: 194 :tags: bug, templates 195 :tickets: 267 196 197 The default template encoding is now utf-8. Previously, the encoding was 198 "ascii", which was standard throughout Python 2. This allows that 199 "magic encoding comment" for utf-8 templates is no longer required. 200 201 202.. changelog:: 203 :version: 1.1.2 204 :released: Sun Mar 1 2020 205 206 .. change:: 207 :tags: feature, commands 208 :tickets: 283 209 210 Added --output-file argument to the Mako command line runner, which allows 211 a specific output file to be selected. Pull request courtesy Björn 212 Dahlgren. 213 214.. changelog:: 215 :version: 1.1.1 216 :released: Mon Jan 20 2020 217 218 .. change:: 219 :tags: bug, py3k 220 :tickets: 310 221 222 Replaced usage of the long-superseded "parser.suite" module in the 223 mako.util package for parsing the python magic encoding comment with the 224 "ast.parse" function introduced many years ago in Python 2.5, as 225 "parser.suite" is emitting deprecation warnings in Python 3.9. 226 227 228 229 .. change:: 230 :tags: bug, ext 231 :tickets: 304 232 233 Added "babel" and "lingua" dependency entries to the setuptools entrypoints 234 for the babel and lingua extensions, so that pkg_resources can check that 235 these extra dependencies are available, raising an informative 236 exception if not. Pull request courtesy sinoroc. 237 238 239 240.. changelog:: 241 :version: 1.1.0 242 :released: Thu Aug 1 2019 243 244 .. change:: 245 :tags: bug, py3k, windows 246 :tickets: 301 247 248 Replaced usage of time.clock() on windows as well as time.time() elsewhere 249 for microsecond timestamps with timeit.default_timer(), as time.clock() is 250 being removed in Python 3.8. Pull request courtesy Christoph Reiter. 251 252 253 .. change:: 254 :tags: bug, py3k 255 :tickets: 295 256 257 Replaced usage of ``inspect.getfullargspec()`` with the vendored version 258 used by SQLAlchemy, Alembic to avoid future deprecation warnings. Also 259 cleans up an additional version of the same function that's apparently 260 been floating around for some time. 261 262 263 .. change:: 264 :tags: changed, setup 265 :tickets: 303 266 267 Removed the "python setup.py test" feature in favor of a straight run of 268 "tox". Per Pypa / pytest developers, "setup.py" commands are in general 269 headed towards deprecation in favor of tox. The tox.ini script has been 270 updated such that running "tox" with no arguments will perform a single run 271 of the test suite against the default installed Python interpreter. 272 273 .. seealso:: 274 275 https://github.com/pypa/setuptools/issues/1684 276 277 https://github.com/pytest-dev/pytest/issues/5534 278 279 .. change:: 280 :tags: changed, py3k, installer 281 :tickets: 249 282 283 Mako 1.1 now supports Python versions: 284 285 * 2.7 286 * 3.4 and higher 287 288 This includes that setup.py no longer includes any conditionals, allowing 289 for a pure Python wheel build, however this is not necessarily part of the 290 Pypi release process as of yet. The test suite also raises for Python 291 deprecation warnings. 292 293 2941.0 295=== 296 297.. changelog:: 298 :version: 1.0.14 299 :released: Sat Jul 20 2019 300 301 .. change:: 302 :tags: feature, template 303 304 The ``n`` filter is now supported in the ``<%page>`` tag. This allows a 305 template to omit the default expression filters throughout a whole 306 template, for those cases where a template-wide filter needs to have 307 default filtering disabled. Pull request courtesy Martin von Gagern. 308 309 .. seealso:: 310 311 :ref:`expression_filtering_nfilter` 312 313 314 315 .. change:: 316 :tags: bug, exceptions 317 318 Fixed issue where the correct file URI would not be shown in the 319 template-formatted exception traceback if the template filename were not 320 known. Additionally fixes an issue where stale filenames would be 321 displayed if a stack trace alternated between different templates. Pull 322 request courtesy Martin von Gagern. 323 324 325.. changelog:: 326 :version: 1.0.13 327 :released: Mon Jul 1 2019 328 329 .. change:: 330 :tags: bug, exceptions 331 332 Improved the line-number tracking for source lines inside of Python ``<% 333 ... %>`` blocks, such that text- and HTML-formatted exception traces such 334 as that of :func:`.html_error_template` now report the correct source line 335 inside the block, rather than the first line of the block itself. 336 Exceptions in ``<%! ... %>`` blocks which get raised while loading the 337 module are still not reported correctly, as these are handled before the 338 Mako code is generated. Pull request courtesy Martin von Gagern. 339 340.. changelog:: 341 :version: 1.0.12 342 :released: Wed Jun 5 2019 343 344 .. change:: 345 :tags: bug, py3k 346 :tickets: 296 347 348 Fixed regression where import refactors in Mako 1.0.11 caused broken 349 imports on Python 3.8. 350 351 352.. changelog:: 353 :version: 1.0.11 354 :released: Fri May 31 2019 355 356 .. change:: 357 :tags: changed 358 359 Updated for additional project metadata in setup.py. Additionally, 360 the code has been reformatted using Black and zimports. 361 362.. changelog:: 363 :version: 1.0.10 364 :released: Fri May 10 2019 365 366 .. change:: 367 :tags: bug, py3k 368 :tickets: 293 369 370 Added a default encoding of "utf-8" when the :class:`.RichTraceback` 371 object retrieves Python source lines from a Python traceback; as these 372 are bytes in Python 3 they need to be decoded so that they can be 373 formatted in the template. 374 375.. changelog:: 376 :version: 1.0.9 377 :released: Mon Apr 15 2019 378 379 .. change:: 380 :tags: bug 381 :tickets: 287 382 383 Further corrected the previous fix for :ticket:`287` as it relied upon 384 an attribute that is monkeypatched by Python's ``ast`` module for some 385 reason, which fails if ``ast`` hasn't been imported; the correct 386 attribute ``Constant.value`` is now used. Also note the issue 387 was mis-numbered in the previous changelog note. 388 389.. changelog:: 390 :version: 1.0.8 391 :released: Wed Mar 20 2019 392 :released: Wed Mar 20 2019 393 394 .. change:: 395 :tags: bug 396 :tickets: 287 397 398 Fixed an element in the AST Python generator which changed 399 for Python 3.8, causing expression generation to fail. 400 401 .. change:: 402 :tags: feature 403 :tickets: 271 404 405 Added ``--output-encoding`` flag to the mako-render script. 406 Pull request courtesy lacsaP. 407 408 .. change:: 409 :tags: bug 410 411 Removed unnecessary "usage" prefix from mako-render script. 412 Pull request courtesy Hugo. 413 414.. changelog:: 415 :version: 1.0.7 416 :released: Thu Jul 13 2017 417 418 .. change:: 419 :tags: bug 420 421 Changed the "print" in the mako-render command to 422 sys.stdout.write(), avoiding the extra newline at the end 423 of the template output. Pull request courtesy 424 Yves Chevallier. 425 426.. changelog:: 427 :version: 1.0.6 428 :released: Wed Nov 9 2016 429 430 .. change:: 431 :tags: feature 432 433 Added new parameter :paramref:`.Template.include_error_handler` . 434 This works like :paramref:`.Template.error_handler` but indicates the 435 handler should take place when this template is included within another 436 template via the ``<%include>`` tag. Pull request courtesy 437 Huayi Zhang. 438 439.. changelog:: 440 :version: 1.0.5 441 :released: Wed Nov 2 2016 442 443 .. change:: 444 :tags: bug 445 446 Updated the Sphinx documentation builder to work with recent 447 versions of Sphinx. 448 449.. changelog:: 450 :version: 1.0.4 451 :released: Thu Mar 10 2016 452 453 .. change:: 454 :tags: feature, test 455 456 The default test runner is now py.test. Running "python setup.py test" 457 will make use of py.test instead of nose. nose still works as a test 458 runner as well, however. 459 460 .. change:: 461 :tags: bug, lexer 462 :pullreq: github:19 463 464 Major improvements to lexing of intricate Python sections which may 465 contain complex backslash sequences, as well as support for the bitwise 466 operator (e.g. pipe symbol) inside of expression sections distinct 467 from the Mako "filter" operator, provided the operator is enclosed 468 within parentheses or brackets. Pull request courtesy Daniel Martin. 469 470 .. change:: 471 :tags: feature 472 473 Added new method :meth:`.Template.list_defs`. Pull request courtesy 474 Jonathan Vanasco. 475 476.. changelog:: 477 :version: 1.0.3 478 :released: Tue Oct 27 2015 479 480 .. change:: 481 :tags: bug, babel 482 483 Fixed an issue where the Babel plugin would not handle a translation 484 symbol that contained non-ascii characters. Pull request courtesy 485 Roman Imankulov. 486 487.. changelog:: 488 :version: 1.0.2 489 :released: Wed Aug 26 2015 490 491 .. change:: 492 :tags: bug, installation 493 :tickets: 249 494 495 The "universal wheel" marker is removed from setup.cfg, because 496 our setup.py currently makes use of conditional dependencies. 497 In :ticket:`249`, the discussion is ongoing on how to correct our 498 setup.cfg / setup.py fully so that we can handle the per-version 499 dependency changes while still maintaining optimal wheel settings, 500 so this issue is not yet fully resolved. 501 502 .. change:: 503 :tags: bug, py3k 504 :tickets: 250 505 506 Repair some calls within the ast module that no longer work on Python3.5; 507 additionally replace the use of ``inspect.getargspec()`` under 508 Python 3 (seems to be called from the TG plugin) to avoid deprecation 509 warnings. 510 511 .. change:: 512 :tags: bug 513 514 Update the Lingua translation extraction plugin to correctly 515 handle templates mixing Python control statements (such as if, 516 for and while) with template fragments. Pull request courtesy 517 Laurent Daverio. 518 519 .. change:: 520 :tags: feature 521 :tickets: 236 522 523 Added ``STOP_RENDERING`` keyword for returning/exiting from a 524 template early, which is a synonym for an empty string ``""``. 525 Previously, the docs suggested a bare 526 ``return``, but this could cause ``None`` to appear in the 527 rendered template result. 528 529 .. seealso:: 530 531 :ref:`syntax_exiting_early` 532 533.. changelog:: 534 :version: 1.0.1 535 :released: Thu Jan 22 2015 536 537 .. change:: 538 :tags: feature 539 540 Added support for Lingua, a translation extraction system as an 541 alternative to Babel. Pull request courtesy Wichert Akkerman. 542 543 .. change:: 544 :tags: bug, py3k 545 546 Modernized the examples/wsgi/run_wsgi.py file for Py3k. 547 Pull requset courtesy Cody Taylor. 548 549.. changelog:: 550 :version: 1.0.0 551 :released: Sun Jun 8 2014 552 553 .. change:: 554 :tags: bug, py2k 555 556 Improved the error re-raise operation when a custom 557 :paramref:`.Template.error_handler` is used that does not handle 558 the exception; the original stack trace etc. is now preserved. 559 Pull request courtesy Manfred Haltner. 560 561 .. change:: 562 :tags: bug, py2k, filters 563 564 Added an html_escape filter that works in "non unicode" mode. 565 Previously, when using ``disable_unicode=True``, the ``u`` filter 566 would fail to handle non-ASCII bytes properly. Pull request 567 courtesy George Xie. 568 569 .. change:: 570 :tags: general 571 572 Compatibility changes; in order to modernize the codebase, Mako 573 is now dropping support for Python 2.4 and Python 2.5 altogether. 574 The source base is now targeted at Python 2.6 and forwards. 575 576 .. change:: 577 :tags: feature 578 579 Template modules now generate a JSON "metadata" structure at the bottom 580 of the source file which includes parseable information about the 581 templates' source file, encoding etc. as well as a mapping of module 582 source lines to template lines, thus replacing the "# SOURCE LINE" 583 markers throughout the source code. The structure also indicates those 584 lines that are explicitly not part of the template's source; the goal 585 here is to allow better integration with coverage and other tools. 586 587 .. change:: 588 :tags: bug, py3k 589 590 Fixed bug in ``decode.<encoding>`` filter where a non-string object 591 would not be correctly interpreted in Python 3. 592 593 .. change:: 594 :tags: bug, py3k 595 :tickets: 227 596 597 Fixed bug in Python parsing logic which would fail on Python 3 598 when a "try/except" targeted a tuple of exception types, rather 599 than a single exception. 600 601 .. change:: 602 :tags: feature 603 604 mako-render is now implemented as a setuptools entrypoint script; 605 a standalone mako.cmd.cmdline() callable is now available, and the 606 system also uses argparse now instead of optparse. Pull request 607 courtesy Derek Harland. 608 609 .. change:: 610 :tags: feature 611 612 The mako-render script will now catch exceptions and run them 613 into the text error handler, and exit with a non-zero exit code. 614 Pull request courtesy Derek Harland. 615 616 .. change:: 617 :tags: bug 618 619 A rework of the mako-render script allows the script to run 620 correctly when given a file pathname that is outside of the current 621 directory, e.g. ``mako-render ../some_template.mako``. In this case, 622 the "template root" defaults to the directory in which the template 623 is located, instead of ".". The script also accepts a new argument 624 ``--template-dir`` which can be specified multiple times to establish 625 template lookup directories. Standard input for templates also works 626 now too. Pull request courtesy Derek Harland. 627 628 .. change:: 629 :tags: feature, py3k 630 :pullreq: github:7 631 632 Support is added for Python 3 "keyword only" arguments, as used in 633 defs. Pull request courtesy Eevee. 634 635 6360.9 637=== 638 639.. changelog:: 640 :version: 0.9.1 641 :released: Thu Dec 26 2013 642 643 .. change:: 644 :tags: bug 645 :tickets: 225 646 647 Fixed bug in Babel plugin where translator comments 648 would be lost if intervening text nodes were encountered. 649 Fix courtesy Ned Batchelder. 650 651 .. change:: 652 :tags: bug 653 :tickets: 654 655 Fixed TGPlugin.render method to support unicode template 656 names in Py2K - courtesy Vladimir Magamedov. 657 658 .. change:: 659 :tags: bug 660 :tickets: 661 662 Fixed an AST issue that was preventing correct operation 663 under alpha versions of Python 3.4. Pullreq courtesy Zer0-. 664 665 .. change:: 666 :tags: bug 667 :tickets: 668 669 Changed the format of the "source encoding" header output 670 by the code generator to use the format ``# -*- coding:%s -*-`` 671 instead of ``# -*- encoding:%s -*-``; the former is more common 672 and compatible with emacs. Courtesy Martin Geisler. 673 674 .. change:: 675 :tags: bug 676 :tickets: 224 677 678 Fixed issue where an old lexer rule prevented a template line 679 which looked like "#*" from being correctly parsed. 680 681.. changelog:: 682 :version: 0.9.0 683 :released: Tue Aug 27 2013 684 685 .. change:: 686 :tags: bug 687 :tickets: 219 688 689 The Context.locals_() method becomes a private underscored 690 method, as this method has a specific internal use. The purpose 691 of Context.kwargs has been clarified, in that it only delivers 692 top level keyword arguments originally passed to template.render(). 693 694 .. change:: 695 :tags: bug 696 :tickets: 697 698 Fixed the babel plugin to properly interpret ${} sections 699 inside of a "call" tag, i.e. <%self:some_tag attr="${_('foo')}"/>. 700 Code that's subject to babel escapes in here needs to be 701 specified as a Python expression, not a literal. This change 702 is backwards incompatible vs. code that is relying upon a _('') 703 translation to be working within a call tag. 704 705 .. change:: 706 :tags: bug 707 :tickets: 187 708 709 The Babel plugin has been repaired to work on Python 3. 710 711 .. change:: 712 :tags: bug 713 :tickets: 207 714 715 Using <%namespace import="*" module="somemodule"/> now 716 skips over module elements that are not explcitly callable, 717 avoiding TypeError when trying to produce partials. 718 719 .. change:: 720 :tags: bug 721 :tickets: 190 722 723 Fixed Py3K bug where a "lambda" expression was not 724 interpreted correctly within a template tag; also 725 fixed in Py2.4. 726 7270.8 728=== 729 730.. changelog:: 731 :version: 0.8.1 732 :released: Fri May 24 2013 733 734 .. change:: 735 :tags: bug 736 :tickets: 216 737 738 Changed setup.py to skip installing markupsafe 739 if Python version is < 2.6 or is between 3.0 and 740 less than 3.3, as Markupsafe now only supports 2.6->2.X, 741 3.3->3.X. 742 743 .. change:: 744 :tags: bug 745 :tickets: 214 746 747 Fixed regression where "entity" filter wasn't 748 converted for py3k properly (added tests.) 749 750 .. change:: 751 :tags: bug 752 :tickets: 212 753 754 Fixed bug where mako-render script wasn't 755 compatible with Py3k. 756 757 .. change:: 758 :tags: bug 759 :tickets: 213 760 761 Cleaned up all the various deprecation/ 762 file warnings when running the tests under 763 various Pythons with warnings turned on. 764 765.. changelog:: 766 :version: 0.8.0 767 :released: Wed Apr 10 2013 768 769 .. change:: 770 :tags: feature 771 :tickets: 772 773 Performance improvement to the 774 "legacy" HTML escape feature, used for XML 775 escaping and when markupsafe isn't present, 776 courtesy George Xie. 777 778 .. change:: 779 :tags: bug 780 :tickets: 209 781 782 Fixed bug whereby an exception in Python 3 783 against a module compiled to the filesystem would 784 fail trying to produce a RichTraceback due to the 785 content being in bytes. 786 787 .. change:: 788 :tags: bug 789 :tickets: 208 790 791 Change default for compile()->reserved_names 792 from tuple to frozenset, as this is expected to be 793 a set by default. 794 795 .. change:: 796 :tags: feature 797 :tickets: 798 799 Code has been reworked to support Python 2.4-> 800 Python 3.xx in place. 2to3 no longer needed. 801 802 .. change:: 803 :tags: feature 804 :tickets: 805 806 Added lexer_cls argument to Template, 807 TemplateLookup, allows alternate Lexer classes 808 to be used. 809 810 .. change:: 811 :tags: feature 812 :tickets: 813 814 Added future_imports parameter to Template 815 and TemplateLookup, renders the __future__ header 816 with desired capabilities at the top of the generated 817 template module. Courtesy Ben Trofatter. 818 8190.7 820=== 821 822.. changelog:: 823 :version: 0.7.3 824 :released: Wed Nov 7 2012 825 826 .. change:: 827 :tags: bug 828 :tickets: 829 830 legacy_html_escape function, used when 831 Markupsafe isn't installed, was using an inline-compiled 832 regexp which causes major slowdowns on Python 3.3; 833 is now precompiled. 834 835 .. change:: 836 :tags: bug 837 :tickets: 201 838 839 AST supporting now supports tuple-packed 840 function arguments inside pure-python def 841 or lambda expressions. 842 843 .. change:: 844 :tags: bug 845 :tickets: 846 847 Fixed Py3K bug in the Babel extension. 848 849 .. change:: 850 :tags: bug 851 :tickets: 852 853 Fixed the "filter" attribute of the 854 <%text> tag so that it pulls locally specified 855 identifiers from the context the same 856 way as that of <%block> and <%filter>. 857 858 .. change:: 859 :tags: bug 860 :tickets: 861 862 Fixed bug in plugin loader to correctly 863 raise exception when non-existent plugin 864 is specified. 865 866.. changelog:: 867 :version: 0.7.2 868 :released: Fri Jul 20 2012 869 870 .. change:: 871 :tags: bug 872 :tickets: 193 873 874 Fixed regression in 0.7.1 where AST 875 parsing for Py2.4 was broken. 876 877.. changelog:: 878 :version: 0.7.1 879 :released: Sun Jul 8 2012 880 881 .. change:: 882 :tags: feature 883 :tickets: 146 884 885 Control lines with no bodies will 886 now succeed, as "pass" is added for these 887 when no statements are otherwise present. 888 Courtesy Ben Trofatter 889 890 .. change:: 891 :tags: bug 892 :tickets: 192 893 894 Fixed some long-broken scoping behavior 895 involving variables declared in defs and such, 896 which only became apparent when 897 the strict_undefined flag was turned on. 898 899 .. change:: 900 :tags: bug 901 :tickets: 191 902 903 Can now use strict_undefined at the 904 same time args passed to def() are used 905 by other elements of the <%def> tag. 906 907.. changelog:: 908 :version: 0.7.0 909 :released: Fri Mar 30 2012 910 911 .. change:: 912 :tags: feature 913 :tickets: 125 914 915 Added new "loop" variable to templates, 916 is provided within a % for block to provide 917 info about the loop such as index, first/last, 918 odd/even, etc. A migration path is also provided 919 for legacy templates via the "enable_loop" argument 920 available on Template, TemplateLookup, and <%page>. 921 Thanks to Ben Trofatter for all 922 the work on this 923 924 .. change:: 925 :tags: feature 926 :tickets: 927 928 Added a real check for "reserved" 929 names, that is names which are never pulled 930 from the context and cannot be passed to 931 the template.render() method. Current names 932 are "context", "loop", "UNDEFINED". 933 934 .. change:: 935 :tags: feature 936 :tickets: 95 937 938 The html_error_template() will now 939 apply Pygments highlighting to the source 940 code displayed in the traceback, if Pygments 941 if available. Courtesy Ben Trofatter 942 943 .. change:: 944 :tags: feature 945 :tickets: 147 946 947 Added support for context managers, 948 i.e. "% with x as e:/ % endwith" support. 949 Courtesy Ben Trofatter 950 951 .. change:: 952 :tags: feature 953 :tickets: 185 954 955 Added class-level flag to CacheImpl 956 "pass_context"; when True, the keyword argument 957 'context' will be passed to get_or_create() 958 containing the Mako Context object. 959 960 .. change:: 961 :tags: bug 962 :tickets: 182 963 964 Fixed some Py3K resource warnings due 965 to filehandles being implicitly closed. 966 967 .. change:: 968 :tags: bug 969 :tickets: 186 970 971 Fixed endless recursion bug when 972 nesting multiple def-calls with content. 973 Thanks to Jeff Dairiki. 974 975 .. change:: 976 :tags: feature 977 :tickets: 978 979 Added Jinja2 to the example 980 benchmark suite, courtesy Vincent Férotin 981 982Older Versions 983============== 984 985.. changelog:: 986 :version: 0.6.2 987 :released: Thu Feb 2 2012 988 989 .. change:: 990 :tags: bug 991 :tickets: 86, 20 992 993 The ${{"foo":"bar"}} parsing issue is fixed!! 994 The legendary Eevee has slain the dragon!. Also fixes quoting issue 995 at. 996 997.. changelog:: 998 :version: 0.6.1 999 :released: Sat Jan 28 2012 1000 1001 .. change:: 1002 :tags: bug 1003 :tickets: 1004 1005 Added special compatibility for the 0.5.0 1006 Cache() constructor, which was preventing file 1007 version checks and not allowing Mako 0.6 to 1008 recompile the module files. 1009 1010.. changelog:: 1011 :version: 0.6.0 1012 :released: Sat Jan 21 2012 1013 1014 .. change:: 1015 :tags: feature 1016 :tickets: 1017 1018 Template caching has been converted into a plugin 1019 system, whereby the usage of Beaker is just the 1020 default plugin. Template and TemplateLookup 1021 now accept a string "cache_impl" parameter which 1022 refers to the name of a cache plugin, defaulting 1023 to the name 'beaker'. New plugins can be 1024 registered as pkg_resources entrypoints under 1025 the group "mako.cache", or registered directly 1026 using mako.cache.register_plugin(). The 1027 core plugin is the mako.cache.CacheImpl 1028 class. 1029 1030 .. change:: 1031 :tags: feature 1032 :tickets: 1033 1034 Added support for Beaker cache regions 1035 in templates. Usage of regions should be considered 1036 as superseding the very obsolete idea of passing in 1037 backend options, timeouts, etc. within templates. 1038 1039 .. change:: 1040 :tags: feature 1041 :tickets: 1042 1043 The 'put' method on Cache is now 1044 'set'. 'put' is there for backwards compatibility. 1045 1046 .. change:: 1047 :tags: feature 1048 :tickets: 1049 1050 The <%def>, <%block> and <%page> tags now accept 1051 any argument named "cache_*", and the key 1052 minus the "cache_" prefix will be passed as keyword 1053 arguments to the CacheImpl methods. 1054 1055 .. change:: 1056 :tags: feature 1057 :tickets: 1058 1059 Template and TemplateLookup now accept an argument 1060 cache_args, which refers to a dictionary containing 1061 cache parameters. The cache_dir, cache_url, cache_type, 1062 cache_timeout arguments are deprecated (will probably 1063 never be removed, however) and can be passed 1064 now as cache_args={'url':<some url>, 'type':'memcached', 1065 'timeout':50, 'dir':'/path/to/some/directory'} 1066 1067 .. change:: 1068 :tags: feature/bug 1069 :tickets: 180 1070 1071 Can now refer to context variables 1072 within extra arguments to <%block>, <%def>, i.e. 1073 <%block name="foo" cache_key="${somekey}">. 1074 Filters can also be used in this way, i.e. 1075 <%def name="foo()" filter="myfilter"> 1076 then template.render(myfilter=some_callable) 1077 1078 .. change:: 1079 :tags: feature 1080 :tickets: 178 1081 1082 Added "--var name=value" option to the mako-render 1083 script, allows passing of kw to the template from 1084 the command line. 1085 1086 .. change:: 1087 :tags: feature 1088 :tickets: 181 1089 1090 Added module_writer argument to Template, 1091 TemplateLookup, allows a callable to be passed which 1092 takes over the writing of the template's module source 1093 file, so that special environment-specific steps 1094 can be taken. 1095 1096 .. change:: 1097 :tags: bug 1098 :tickets: 142 1099 1100 The exception message in the html_error_template 1101 is now escaped with the HTML filter. 1102 1103 .. change:: 1104 :tags: bug 1105 :tickets: 173 1106 1107 Added "white-space:pre" style to html_error_template() 1108 for code blocks so that indentation is preserved 1109 1110 .. change:: 1111 :tags: bug 1112 :tickets: 175 1113 1114 The "benchmark" example is now Python 3 compatible 1115 (even though several of those old template libs aren't 1116 available on Py3K, so YMMV) 1117 1118 1119.. changelog:: 1120 :version: 0.5.0 1121 :released: Wed Sep 28 2011 1122 1123 .. change:: 1124 :tags: 1125 :tickets: 174 1126 1127 A Template is explicitly disallowed 1128 from having a url that normalizes to relative outside 1129 of the root. That is, if the Lookup is based 1130 at /home/mytemplates, an include that would place 1131 the ultimate template at 1132 /home/mytemplates/../some_other_directory, 1133 i.e. outside of /home/mytemplates, 1134 is disallowed. This usage was never intended 1135 despite the lack of an explicit check. 1136 The main issue this causes 1137 is that module files can be written outside 1138 of the module root (or raise an error, if file perms aren't 1139 set up), and can also lead to the same template being 1140 cached in the lookup under multiple, relative roots. 1141 TemplateLookup instead has always supported multiple 1142 file roots for this purpose. 1143 1144 1145.. changelog:: 1146 :version: 0.4.2 1147 :released: Fri Aug 5 2011 1148 1149 .. change:: 1150 :tags: 1151 :tickets: 170 1152 1153 Fixed bug regarding <%call>/def calls w/ content 1154 whereby the identity of the "caller" callable 1155 inside the <%def> would be corrupted by the 1156 presence of another <%call> in the same block. 1157 1158 .. change:: 1159 :tags: 1160 :tickets: 169 1161 1162 Fixed the babel plugin to accommodate <%block> 1163 1164.. changelog:: 1165 :version: 0.4.1 1166 :released: Wed Apr 6 2011 1167 1168 .. change:: 1169 :tags: 1170 :tickets: 164 1171 1172 New tag: <%block>. A variant on <%def> that 1173 evaluates its contents in-place. 1174 Can be named or anonymous, 1175 the named version is intended for inheritance 1176 layouts where any given section can be 1177 surrounded by the <%block> tag in order for 1178 it to become overrideable by inheriting 1179 templates, without the need to specify a 1180 top-level <%def> plus explicit call. 1181 Modified scoping and argument rules as well as a 1182 more strictly enforced usage scheme make it ideal 1183 for this purpose without at all replacing most 1184 other things that defs are still good for. 1185 Lots of new docs. 1186 1187 .. change:: 1188 :tags: 1189 :tickets: 165 1190 1191 a slight adjustment to the "highlight" logic 1192 for generating template bound stacktraces. 1193 Will stick to known template source lines 1194 without any extra guessing. 1195 1196.. changelog:: 1197 :version: 0.4.0 1198 :released: Sun Mar 6 2011 1199 1200 .. change:: 1201 :tags: 1202 :tickets: 1203 1204 A 20% speedup for a basic two-page 1205 inheritance setup rendering 1206 a table of escaped data 1207 (see http://techspot.zzzeek.org/2010/11/19/quick-mako-vs.-jinja-speed-test/). 1208 A few configurational changes which 1209 affect those in the I-don't-do-unicode 1210 camp should be noted below. 1211 1212 .. change:: 1213 :tags: 1214 :tickets: 1215 1216 The FastEncodingBuffer is now used 1217 by default instead of cStringIO or StringIO, 1218 regardless of whether output_encoding 1219 is set to None or not. FEB is faster than 1220 both. Only StringIO allows bytestrings 1221 of unknown encoding to pass right 1222 through, however - while it is of course 1223 not recommended to send bytestrings of unknown 1224 encoding to the output stream, this 1225 mode of usage can be re-enabled by 1226 setting the flag bytestring_passthrough 1227 to True. 1228 1229 .. change:: 1230 :tags: 1231 :tickets: 1232 1233 disable_unicode mode requires that 1234 output_encoding be set to None - it also 1235 forces the bytestring_passthrough flag 1236 to True. 1237 1238 .. change:: 1239 :tags: 1240 :tickets: 156 1241 1242 the <%namespace> tag raises an error 1243 if the 'template' and 'module' attributes 1244 are specified at the same time in 1245 one tag. A different class is used 1246 for each case which allows a reduction in 1247 runtime conditional logic and function 1248 call overhead. 1249 1250 .. change:: 1251 :tags: 1252 :tickets: 159 1253 1254 the keys() in the Context, as well as 1255 it's internal _data dictionary, now 1256 include just what was specified to 1257 render() as well as Mako builtins 1258 'caller', 'capture'. The contents 1259 of __builtin__ are no longer copied. 1260 Thanks to Daniel Lopez for pointing 1261 this out. 1262 1263 1264.. changelog:: 1265 :version: 0.3.6 1266 :released: Sat Nov 13 2010 1267 1268 .. change:: 1269 :tags: 1270 :tickets: 126 1271 1272 Documentation is on Sphinx. 1273 1274 .. change:: 1275 :tags: 1276 :tickets: 154 1277 1278 Beaker is now part of "extras" in 1279 setup.py instead of "install_requires". 1280 This to produce a lighter weight install 1281 for those who don't use the caching 1282 as well as to conform to Pyramid 1283 deployment practices. 1284 1285 .. change:: 1286 :tags: 1287 :tickets: 153 1288 1289 The Beaker import (or attempt thereof) 1290 is delayed until actually needed; 1291 this to remove the performance penalty 1292 from startup, particularly for 1293 "single execution" environments 1294 such as shell scripts. 1295 1296 .. change:: 1297 :tags: 1298 :tickets: 155 1299 1300 Patch to lexer to not generate an empty 1301 '' write in the case of backslash-ended 1302 lines. 1303 1304 .. change:: 1305 :tags: 1306 :tickets: 148 1307 1308 Fixed missing \**extra collection in 1309 setup.py which prevented setup.py 1310 from running 2to3 on install. 1311 1312 .. change:: 1313 :tags: 1314 :tickets: 1315 1316 New flag on Template, TemplateLookup - 1317 strict_undefined=True, will cause 1318 variables not found in the context to 1319 raise a NameError immediately, instead of 1320 defaulting to the UNDEFINED value. 1321 1322 .. change:: 1323 :tags: 1324 :tickets: 1325 1326 The range of Python identifiers that 1327 are considered "undefined", meaning they 1328 are pulled from the context, has been 1329 trimmed back to not include variables 1330 declared inside of expressions (i.e. from 1331 list comprehensions), as well as 1332 in the argument list of lambdas. This 1333 to better support the strict_undefined 1334 feature. The change should be 1335 fully backwards-compatible but involved 1336 a little bit of tinkering in the AST code, 1337 which hadn't really been touched for 1338 a couple of years, just FYI. 1339 1340.. changelog:: 1341 :version: 0.3.5 1342 :released: Sun Oct 24 2010 1343 1344 .. change:: 1345 :tags: 1346 :tickets: 141 1347 1348 The <%namespace> tag allows expressions 1349 for the `file` argument, i.e. with ${}. 1350 The `context` variable, if needed, 1351 must be referenced explicitly. 1352 1353 .. change:: 1354 :tags: 1355 :tickets: 1356 1357 ${} expressions embedded in tags, 1358 such as <%foo:bar x="${...}">, now 1359 allow multiline Python expressions. 1360 1361 .. change:: 1362 :tags: 1363 :tickets: 1364 1365 Fixed previously non-covered regular 1366 expression, such that using a ${} expression 1367 inside of a tag element that doesn't allow 1368 them raises a CompileException instead of 1369 silently failing. 1370 1371 .. change:: 1372 :tags: 1373 :tickets: 151 1374 1375 Added a try/except around "import markupsafe". 1376 This to support GAE which can't run markupsafe. No idea whatsoever if the 1377 install_requires in setup.py also breaks GAE, 1378 couldn't get an answer on this. 1379 1380.. changelog:: 1381 :version: 0.3.4 1382 :released: Tue Jun 22 2010 1383 1384 .. change:: 1385 :tags: 1386 :tickets: 1387 1388 Now using MarkupSafe for HTML escaping, 1389 i.e. in place of cgi.escape(). Faster 1390 C-based implementation and also escapes 1391 single quotes for additional security. 1392 Supports the __html__ attribute for 1393 the given expression as well. 1394 1395 When using "disable_unicode" mode, 1396 a pure Python HTML escaper function 1397 is used which also quotes single quotes. 1398 1399 Note that Pylons by default doesn't 1400 use Mako's filter - check your 1401 environment.py file. 1402 1403 .. change:: 1404 :tags: 1405 :tickets: 137 1406 1407 Fixed call to "unicode.strip" in 1408 exceptions.text_error_template which 1409 is not Py3k compatible. 1410 1411.. changelog:: 1412 :version: 0.3.3 1413 :released: Mon May 31 2010 1414 1415 .. change:: 1416 :tags: 1417 :tickets: 135 1418 1419 Added conditional to RichTraceback 1420 such that if no traceback is passed 1421 and sys.exc_info() has been reset, 1422 the formatter just returns blank 1423 for the "traceback" portion. 1424 1425 .. change:: 1426 :tags: 1427 :tickets: 131 1428 1429 Fixed sometimes incorrect usage of 1430 exc.__class__.__name__ 1431 in html/text error templates when using 1432 Python 2.4 1433 1434 .. change:: 1435 :tags: 1436 :tickets: 1437 1438 Fixed broken @property decorator on 1439 template.last_modified 1440 1441 .. change:: 1442 :tags: 1443 :tickets: 132 1444 1445 Fixed error formatting when a stacktrace 1446 line contains no line number, as in when 1447 inside an eval/exec-generated function. 1448 1449 .. change:: 1450 :tags: 1451 :tickets: 1452 1453 When a .py is being created, the tempfile 1454 where the source is stored temporarily is 1455 now made in the same directory as that of 1456 the .py file. This ensures that the two 1457 files share the same filesystem, thus 1458 avoiding cross-filesystem synchronization 1459 issues. Thanks to Charles Cazabon. 1460 1461.. changelog:: 1462 :version: 0.3.2 1463 :released: Thu Mar 11 2010 1464 1465 .. change:: 1466 :tags: 1467 :tickets: 116 1468 1469 Calling a def from the top, via 1470 template.get_def(...).render() now checks the 1471 argument signature the same way as it did in 1472 0.2.5, so that TypeError is not raised. 1473 reopen of 1474 1475.. changelog:: 1476 :version: 0.3.1 1477 :released: Sun Mar 7 2010 1478 1479 .. change:: 1480 :tags: 1481 :tickets: 129 1482 1483 Fixed incorrect dir name in setup.py 1484 1485.. changelog:: 1486 :version: 0.3.0 1487 :released: Fri Mar 5 2010 1488 1489 .. change:: 1490 :tags: 1491 :tickets: 123 1492 1493 Python 2.3 support is dropped. 1494 1495 .. change:: 1496 :tags: 1497 :tickets: 119 1498 1499 Python 3 support is added ! See README.py3k 1500 for installation and testing notes. 1501 1502 .. change:: 1503 :tags: 1504 :tickets: 127 1505 1506 Unit tests now run with nose. 1507 1508 .. change:: 1509 :tags: 1510 :tickets: 99 1511 1512 Source code escaping has been simplified. 1513 In particular, module source files are now 1514 generated with the Python "magic encoding 1515 comment", and source code is passed through 1516 mostly unescaped, except for that code which 1517 is regenerated from parsed Python source. 1518 This fixes usage of unicode in 1519 <%namespace:defname> tags. 1520 1521 .. change:: 1522 :tags: 1523 :tickets: 122 1524 1525 RichTraceback(), html_error_template().render(), 1526 text_error_template().render() now accept "error" 1527 and "traceback" as optional arguments, and 1528 these are now actually used. 1529 1530 .. change:: 1531 :tags: 1532 :tickets: 1533 1534 The exception output generated when 1535 format_exceptions=True will now be as a Python 1536 unicode if it occurred during render_unicode(), 1537 or an encoded string if during render(). 1538 1539 .. change:: 1540 :tags: 1541 :tickets: 112 1542 1543 A percent sign can be emitted as the first 1544 non-whitespace character on a line by escaping 1545 it as in "%%". 1546 1547 .. change:: 1548 :tags: 1549 :tickets: 94 1550 1551 Template accepts empty control structure, i.e. 1552 % if: %endif, etc. 1553 1554 .. change:: 1555 :tags: 1556 :tickets: 116 1557 1558 The <%page args> tag can now be used in a base 1559 inheriting template - the full set of render() 1560 arguments are passed down through the inherits 1561 chain. Undeclared arguments go into \**pageargs 1562 as usual. 1563 1564 .. change:: 1565 :tags: 1566 :tickets: 109 1567 1568 defs declared within a <%namespace> section, an 1569 uncommon feature, have been improved. The defs 1570 no longer get doubly-rendered in the body() scope, 1571 and now allow local variable assignment without 1572 breakage. 1573 1574 .. change:: 1575 :tags: 1576 :tickets: 128 1577 1578 Windows paths are handled correctly if a Template 1579 is passed only an absolute filename (i.e. with c: 1580 drive etc.) and no URI - the URI is converted 1581 to a forward-slash path and module_directory 1582 is treated as a windows path. 1583 1584 .. change:: 1585 :tags: 1586 :tickets: 73 1587 1588 TemplateLookup raises TopLevelLookupException for 1589 a given path that is a directory, not a filename, 1590 instead of passing through to the template to 1591 generate IOError. 1592 1593 1594.. changelog:: 1595 :version: 0.2.6 1596 :released: 1597 1598 .. change:: 1599 :tags: 1600 :tickets: 1601 1602 Fix mako function decorators to preserve the 1603 original function's name in all cases. Patch 1604 from Scott Torborg. 1605 1606 .. change:: 1607 :tags: 1608 :tickets: 118 1609 1610 Support the <%namespacename:defname> syntax in 1611 the babel extractor. 1612 1613 .. change:: 1614 :tags: 1615 :tickets: 88 1616 1617 Further fixes to unicode handling of .py files with the 1618 html_error_template. 1619 1620.. changelog:: 1621 :version: 0.2.5 1622 :released: Mon Sep 7 2009 1623 1624 .. change:: 1625 :tags: 1626 :tickets: 1627 1628 Added a "decorator" kw argument to <%def>, 1629 allows custom decoration functions to wrap 1630 rendering callables. Mainly intended for 1631 custom caching algorithms, not sure what 1632 other uses there may be (but there may be). 1633 Examples are in the "filtering" docs. 1634 1635 .. change:: 1636 :tags: 1637 :tickets: 101 1638 1639 When Mako creates subdirectories in which 1640 to store templates, it uses the more 1641 permissive mode of 0775 instead of 0750, 1642 helping out with certain multi-process 1643 scenarios. Note that the mode is always 1644 subject to the restrictions of the existing 1645 umask. 1646 1647 .. change:: 1648 :tags: 1649 :tickets: 104 1650 1651 Fixed namespace.__getattr__() to raise 1652 AttributeError on attribute not found 1653 instead of RuntimeError. 1654 1655 .. change:: 1656 :tags: 1657 :tickets: 97 1658 1659 Added last_modified accessor to Template, 1660 returns the time.time() when the module 1661 was created. 1662 1663 .. change:: 1664 :tags: 1665 :tickets: 102 1666 1667 Fixed lexing support for whitespace 1668 around '=' sign in defs. 1669 1670 .. change:: 1671 :tags: 1672 :tickets: 108 1673 1674 Removed errant "lower()" in the lexer which 1675 was causing tags to compile with 1676 case-insensitive names, thus messing up 1677 custom <%call> names. 1678 1679 .. change:: 1680 :tags: 1681 :tickets: 110 1682 1683 added "mako.__version__" attribute to 1684 the base module. 1685 1686.. changelog:: 1687 :version: 0.2.4 1688 :released: Tue Dec 23 2008 1689 1690 .. change:: 1691 :tags: 1692 :tickets: 1693 1694 Fixed compatibility with Jython 2.5b1. 1695 1696.. changelog:: 1697 :version: 0.2.3 1698 :released: Sun Nov 23 2008 1699 1700 .. change:: 1701 :tags: 1702 :tickets: 1703 1704 the <%namespacename:defname> syntax described at 1705 http://techspot.zzzeek.org/?p=28 has now 1706 been added as a built in syntax, and is recommended 1707 as a more modern syntax versus <%call expr="expression">. 1708 The %call tag itself will always remain, 1709 with <%namespacename:defname> presenting a more HTML-like 1710 alternative to calling defs, both plain and 1711 nested. Many examples of the new syntax are in the 1712 "Calling a def with embedded content" section 1713 of the docs. 1714 1715 .. change:: 1716 :tags: 1717 :tickets: 1718 1719 added support for Jython 2.5. 1720 1721 .. change:: 1722 :tags: 1723 :tickets: 1724 1725 cache module now uses Beaker's CacheManager 1726 object directly, so that all cache types are included. 1727 memcached is available as both "ext:memcached" and 1728 "memcached", the latter for backwards compatibility. 1729 1730 .. change:: 1731 :tags: 1732 :tickets: 1733 1734 added "cache" accessor to Template, Namespace. 1735 e.g. ${local.cache.get('somekey')} or 1736 template.cache.invalidate_body() 1737 1738 .. change:: 1739 :tags: 1740 :tickets: 1741 1742 added "cache_enabled=True" flag to Template, 1743 TemplateLookup. Setting this to False causes cache 1744 operations to "pass through" and execute every time; 1745 this flag should be integrated in Pylons with its own 1746 cache_enabled configuration setting. 1747 1748 .. change:: 1749 :tags: 1750 :tickets: 92 1751 1752 the Cache object now supports invalidate_def(name), 1753 invalidate_body(), invalidate_closure(name), 1754 invalidate(key), which will remove the given key 1755 from the cache, if it exists. The cache arguments 1756 (i.e. storage type) are derived from whatever has 1757 been already persisted for that template. 1758 1759 .. change:: 1760 :tags: 1761 :tickets: 1762 1763 For cache changes to work fully, Beaker 1.1 is required. 1764 1.0.1 and up will work as well with the exception of 1765 cache expiry. Note that Beaker 1.1 is **required** 1766 for applications which use dynamically generated keys, 1767 since previous versions will permanently store state in memory 1768 for each individual key, thus consuming all available 1769 memory for an arbitrarily large number of distinct 1770 keys. 1771 1772 .. change:: 1773 :tags: 1774 :tickets: 93 1775 1776 fixed bug whereby an <%included> template with 1777 <%page> args named the same as a __builtin__ would not 1778 honor the default value specified in <%page> 1779 1780 .. change:: 1781 :tags: 1782 :tickets: 88 1783 1784 fixed the html_error_template not handling tracebacks from 1785 normal .py files with a magic encoding comment 1786 1787 .. change:: 1788 :tags: 1789 :tickets: 1790 1791 RichTraceback() now accepts an optional traceback object 1792 to be used in place of sys.exc_info()[2]. html_error_template() 1793 and text_error_template() accept an optional 1794 render()-time argument "traceback" which is passed to the 1795 RichTraceback object. 1796 1797 .. change:: 1798 :tags: 1799 :tickets: 1800 1801 added ModuleTemplate class, which allows the construction 1802 of a Template given a Python module generated by a previous 1803 Template. This allows Python modules alone to be used 1804 as templates with no compilation step. Source code 1805 and template source are optional but allow error reporting 1806 to work correctly. 1807 1808 .. change:: 1809 :tags: 1810 :tickets: 90 1811 1812 fixed Python 2.3 compat. in mako.pyparser 1813 1814 .. change:: 1815 :tags: 1816 :tickets: 1817 1818 fix Babel 0.9.3 compatibility; stripping comment tags is now 1819 optional (and enabled by default). 1820 1821.. changelog:: 1822 :version: 0.2.2 1823 :released: Mon Jun 23 2008 1824 1825 .. change:: 1826 :tags: 1827 :tickets: 87 1828 1829 cached blocks now use the current context when rendering 1830 an expired section, instead of the original context 1831 passed in 1832 1833 .. change:: 1834 :tags: 1835 :tickets: 1836 1837 fixed a critical issue regarding caching, whereby 1838 a cached block would raise an error when called within a 1839 cache-refresh operation that was initiated after the 1840 initiating template had completed rendering. 1841 1842.. changelog:: 1843 :version: 0.2.1 1844 :released: Mon Jun 16 2008 1845 1846 .. change:: 1847 :tags: 1848 :tickets: 1849 1850 fixed bug where 'output_encoding' parameter would prevent 1851 render_unicode() from returning a unicode object. 1852 1853 .. change:: 1854 :tags: 1855 :tickets: 1856 1857 bumped magic number, which forces template recompile for 1858 this version (fixes incompatible compile symbols from 0.1 1859 series). 1860 1861 .. change:: 1862 :tags: 1863 :tickets: 1864 1865 added a few docs for cache options, specifically those that 1866 help with memcached. 1867 1868.. changelog:: 1869 :version: 0.2.0 1870 :released: Tue Jun 3 2008 1871 1872 .. change:: 1873 :tags: 1874 :tickets: 1875 1876 Speed improvements (as though we needed them, but people 1877 contributed and there you go): 1878 1879 .. change:: 1880 :tags: 1881 :tickets: 77 1882 1883 added "bytestring passthru" mode, via 1884 `disable_unicode=True` argument passed to Template or 1885 TemplateLookup. All unicode-awareness and filtering is 1886 turned off, and template modules are generated with 1887 the appropriate magic encoding comment. In this mode, 1888 template expressions can only receive raw bytestrings 1889 or Unicode objects which represent straight ASCII, and 1890 render_unicode() may not be used if multibyte 1891 characters are present. When enabled, speed 1892 improvement around 10-20%. (courtesy 1893 anonymous guest) 1894 1895 .. change:: 1896 :tags: 1897 :tickets: 76 1898 1899 inlined the "write" function of Context into a local 1900 template variable. This affords a 12-30% speedup in 1901 template render time. (idea courtesy same anonymous 1902 guest) 1903 1904 .. change:: 1905 :tags: 1906 :tickets: 1907 1908 New Features, API changes: 1909 1910 .. change:: 1911 :tags: 1912 :tickets: 62 1913 1914 added "attr" accessor to namespaces. Returns 1915 attributes configured as module level attributes, i.e. 1916 within <%! %> sections. i.e.:: 1917 1918 # somefile.html 1919 <%! 1920 foo = 27 1921 %> 1922 1923 # some other template 1924 <%namespace name="myns" file="somefile.html"/> 1925 ${myns.attr.foo} 1926 1927 The slight backwards incompatibility here is, you 1928 can't have namespace defs named "attr" since the 1929 "attr" descriptor will occlude it. 1930 1931 .. change:: 1932 :tags: 1933 :tickets: 78 1934 1935 cache_key argument can now render arguments passed 1936 directly to the %page or %def, i.e. <%def 1937 name="foo(x)" cached="True" cache_key="${x}"/> 1938 1939 .. change:: 1940 :tags: 1941 :tickets: 1942 1943 some functions on Context are now private: 1944 _push_buffer(), _pop_buffer(), 1945 caller_stack._push_frame(), caller_stack._pop_frame(). 1946 1947 .. change:: 1948 :tags: 1949 :tickets: 56, 81 1950 1951 added a runner script "mako-render" which renders 1952 standard input as a template to stdout 1953 1954 .. change:: 1955 :tags: bugfixes 1956 :tickets: 83, 84 1957 1958 can now use most names from __builtins__ as variable 1959 names without explicit declaration (i.e. 'id', 1960 'exception', 'range', etc.) 1961 1962 .. change:: 1963 :tags: bugfixes 1964 :tickets: 84 1965 1966 can also use builtin names as local variable names 1967 (i.e. dict, locals) (came from fix for) 1968 1969 .. change:: 1970 :tags: bugfixes 1971 :tickets: 68 1972 1973 fixed bug in python generation when variable names are 1974 used with identifiers like "else", "finally", etc. 1975 inside them 1976 1977 .. change:: 1978 :tags: bugfixes 1979 :tickets: 69 1980 1981 fixed codegen bug which occurred when using <%page> 1982 level caching, combined with an expression-based 1983 cache_key, combined with the usage of <%namespace 1984 import="*"/> - fixed lexer exceptions not cleaning up 1985 temporary files, which could lead to a maximum number 1986 of file descriptors used in the process 1987 1988 .. change:: 1989 :tags: bugfixes 1990 :tickets: 71 1991 1992 fixed issue with inline format_exceptions that was 1993 producing blank exception pages when an inheriting 1994 template is present 1995 1996 .. change:: 1997 :tags: bugfixes 1998 :tickets: 1999 2000 format_exceptions will apply the encoding options of 2001 html_error_template() to the buffered output 2002 2003 .. change:: 2004 :tags: bugfixes 2005 :tickets: 75 2006 2007 rewrote the "whitespace adjuster" function to work 2008 with more elaborate combinations of quotes and 2009 comments 2010 2011 2012.. changelog:: 2013 :version: 0.1.10 2014 :released: 2015 2016 .. change:: 2017 :tags: 2018 :tickets: 2019 2020 fixed propagation of 'caller' such that nested %def calls 2021 within a <%call> tag's argument list propigates 'caller' 2022 to the %call function itself (propigates to the inner 2023 calls too, this is a slight side effect which previously 2024 existed anyway) 2025 2026 .. change:: 2027 :tags: 2028 :tickets: 2029 2030 fixed bug where local.get_namespace() could put an 2031 incorrect "self" in the current context 2032 2033 .. change:: 2034 :tags: 2035 :tickets: 2036 2037 fixed another namespace bug where the namespace functions 2038 did not have access to the correct context containing 2039 their 'self' and 'parent' 2040 2041.. changelog:: 2042 :version: 0.1.9 2043 :released: 2044 2045 .. change:: 2046 :tags: 2047 :tickets: 47 2048 2049 filters.Decode filter can also accept a non-basestring 2050 object and will call str() + unicode() on it 2051 2052 .. change:: 2053 :tags: 2054 :tickets: 53 2055 2056 comments can be placed at the end of control lines, 2057 i.e. if foo: # a comment,, thanks to 2058 Paul Colomiets 2059 2060 .. change:: 2061 :tags: 2062 :tickets: 16 2063 2064 fixed expressions and page tag arguments and with embedded 2065 newlines in CRLF templates, follow up to, thanks 2066 Eric Woroshow 2067 2068 .. change:: 2069 :tags: 2070 :tickets: 51 2071 2072 added an IOError catch for source file not found in RichTraceback 2073 exception reporter 2074 2075.. changelog:: 2076 :version: 0.1.8 2077 :released: Tue Jun 26 2007 2078 2079 .. change:: 2080 :tags: 2081 :tickets: 2082 2083 variable names declared in render methods by internal 2084 codegen prefixed by "__M_" to prevent name collisions 2085 with user code 2086 2087 .. change:: 2088 :tags: 2089 :tickets: 45 2090 2091 added a Babel (http://babel.edgewall.org/) extractor entry 2092 point, allowing extraction of gettext messages directly from 2093 mako templates via Babel 2094 2095 .. change:: 2096 :tags: 2097 :tickets: 2098 2099 fix to turbogears plugin to work with dot-separated names 2100 (i.e. load_template('foo.bar')). also takes file extension 2101 as a keyword argument (default is 'mak'). 2102 2103 .. change:: 2104 :tags: 2105 :tickets: 35 2106 2107 more tg fix: fixed, allowing string-based 2108 templates with tgplugin even if non-compatible args were sent 2109 2110.. changelog:: 2111 :version: 0.1.7 2112 :released: Wed Jun 13 2007 2113 2114 .. change:: 2115 :tags: 2116 :tickets: 2117 2118 one small fix to the unit tests to support python 2.3 2119 2120 .. change:: 2121 :tags: 2122 :tickets: 2123 2124 a slight hack to how cache.py detects Beaker's memcached, 2125 works around unexplained import behavior observed on some 2126 python 2.3 installations 2127 2128.. changelog:: 2129 :version: 0.1.6 2130 :released: Fri May 18 2007 2131 2132 .. change:: 2133 :tags: 2134 :tickets: 2135 2136 caching is now supplied directly by Beaker, which has 2137 all of MyghtyUtils merged into it now. The latest Beaker 2138 (0.7.1) also fixes a bug related to how Mako was using the 2139 cache API. 2140 2141 .. change:: 2142 :tags: 2143 :tickets: 34 2144 2145 fix to module_directory path generation when the path is "./" 2146 2147 .. change:: 2148 :tags: 2149 :tickets: 35 2150 2151 TGPlugin passes options to string-based templates 2152 2153 .. change:: 2154 :tags: 2155 :tickets: 28 2156 2157 added an explicit stack frame step to template runtime, which 2158 allows much simpler and hopefully bug-free tracking of 'caller', 2159 fixes 2160 2161 .. change:: 2162 :tags: 2163 :tickets: 2164 2165 if plain Python defs are used with <%call>, a decorator 2166 @runtime.supports_callable exists to ensure that the "caller" 2167 stack is properly handled for the def. 2168 2169 .. change:: 2170 :tags: 2171 :tickets: 37 2172 2173 fix to RichTraceback and exception reporting to get template 2174 source code as a unicode object 2175 2176 .. change:: 2177 :tags: 2178 :tickets: 39 2179 2180 html_error_template includes options "full=True", "css=True" 2181 which control generation of HTML tags, CSS 2182 2183 .. change:: 2184 :tags: 2185 :tickets: 40 2186 2187 added the 'encoding_errors' parameter to Template/TemplateLookup 2188 for specifying the error handler associated with encoding to 2189 'output_encoding' 2190 2191 .. change:: 2192 :tags: 2193 :tickets: 37 2194 2195 the Template returned by html_error_template now defaults to 2196 output_encoding=sys.getdefaultencoding(), 2197 encoding_errors='htmlentityreplace' 2198 2199 .. change:: 2200 :tags: 2201 :tickets: 2202 2203 control lines, i.e. % lines, support backslashes to continue long 2204 lines (#32) 2205 2206 .. change:: 2207 :tags: 2208 :tickets: 2209 2210 fixed codegen bug when defining <%def> within <%call> within <%call> 2211 2212 .. change:: 2213 :tags: 2214 :tickets: 2215 2216 leading utf-8 BOM in template files is honored according to pep-0263 2217 2218.. changelog:: 2219 :version: 0.1.5 2220 :released: Sat Mar 31 2007 2221 2222 .. change:: 2223 :tags: 2224 :tickets: 26 2225 2226 AST expression generation - added in just about everything 2227 expression-wise from the AST module 2228 2229 .. change:: 2230 :tags: 2231 :tickets: 27 2232 2233 AST parsing, properly detects imports of the form "import foo.bar" 2234 2235 .. change:: 2236 :tags: 2237 :tickets: 2238 2239 fix to lexing of <%docs> tag nested in other tags 2240 2241 .. change:: 2242 :tags: 2243 :tickets: 29 2244 2245 fix to context-arguments inside of <%include> tag which broke 2246 during 0.1.4 2247 2248 .. change:: 2249 :tags: 2250 :tickets: 2251 2252 added "n" filter, disables *all* filters normally applied to an expression 2253 via <%page> or default_filters (but not those within the filter) 2254 2255 .. change:: 2256 :tags: 2257 :tickets: 2258 2259 added buffer_filters argument, defines filters applied to the return value 2260 of buffered/cached/filtered %defs, after all filters defined with the %def 2261 itself have been applied. allows the creation of default expression filters 2262 that let the output of return-valued %defs "opt out" of that filtering 2263 via passing special attributes or objects. 2264 2265.. changelog:: 2266 :version: 0.1.4 2267 :released: Sat Mar 10 2007 2268 2269 .. change:: 2270 :tags: 2271 :tickets: 2272 2273 got defs-within-defs to be cacheable 2274 2275 .. change:: 2276 :tags: 2277 :tickets: 23 2278 2279 fixes to code parsing/whitespace adjusting where plain python comments 2280 may contain quote characters 2281 2282 .. change:: 2283 :tags: 2284 :tickets: 2285 2286 fix to variable scoping for identifiers only referenced within 2287 functions 2288 2289 .. change:: 2290 :tags: 2291 :tickets: 2292 2293 added a path normalization step to lookup so URIs like 2294 "/foo/bar/../etc/../foo" pre-process the ".." tokens before checking 2295 the filesystem 2296 2297 .. change:: 2298 :tags: 2299 :tickets: 2300 2301 fixed/improved "caller" semantics so that undefined caller is 2302 "UNDEFINED", propigates __nonzero__ method so it evaulates to False if 2303 not present, True otherwise. this way you can say % if caller:\n 2304 ${caller.body()}\n% endif 2305 2306 .. change:: 2307 :tags: 2308 :tickets: 2309 2310 <%include> has an "args" attribute that can pass arguments to the 2311 called template (keyword arguments only, must be declared in that 2312 page's <%page> tag.) 2313 2314 .. change:: 2315 :tags: 2316 :tickets: 2317 2318 <%include> plus arguments is also programmatically available via 2319 self.include_file(<filename>, \**kwargs) 2320 2321 .. change:: 2322 :tags: 2323 :tickets: 24 2324 2325 further escaping added for multibyte expressions in %def, %call 2326 attributes 2327 2328.. changelog:: 2329 :version: 0.1.3 2330 :released: Wed Feb 21 2007 2331 2332 .. change:: 2333 :tags: 2334 :tickets: 2335 2336 ***Small Syntax Change*** - the single line comment character is now 2337 *two* hash signs, i.e. "## this is a comment". This avoids a common 2338 collection with CSS selectors. 2339 2340 .. change:: 2341 :tags: 2342 :tickets: 2343 2344 the magic "coding" comment (i.e. # coding:utf-8) will still work with 2345 either one "#" sign or two for now; two is preferred going forward, i.e. 2346 ## coding:<someencoding>. 2347 2348 .. change:: 2349 :tags: 2350 :tickets: 2351 2352 new multiline comment form: "<%doc> a comment </%doc>" 2353 2354 .. change:: 2355 :tags: 2356 :tickets: 2357 2358 UNDEFINED evaluates to False 2359 2360 .. change:: 2361 :tags: 2362 :tickets: 2363 2364 improvement to scoping of "caller" variable when using <%call> tag 2365 2366 .. change:: 2367 :tags: 2368 :tickets: 2369 2370 added lexer error for unclosed control-line (%) line 2371 2372 .. change:: 2373 :tags: 2374 :tickets: 2375 2376 added "preprocessor" argument to Template, TemplateLookup - is a single 2377 callable or list of callables which will be applied to the template text 2378 before lexing. given the text as an argument, returns the new text. 2379 2380 .. change:: 2381 :tags: 2382 :tickets: 2383 2384 added mako.ext.preprocessors package, contains one preprocessor so far: 2385 'convert_comments', which will convert single # comments to the new ## 2386 format 2387 2388.. changelog:: 2389 :version: 0.1.2 2390 :released: Thu Feb 1 2007 2391 2392 .. change:: 2393 :tags: 2394 :tickets: 11 2395 2396 fix to parsing of code/expression blocks to insure that non-ascii 2397 characters, combined with a template that indicates a non-standard 2398 encoding, are expanded into backslash-escaped glyphs before being AST 2399 parsed 2400 2401 .. change:: 2402 :tags: 2403 :tickets: 2404 2405 all template lexing converts the template to unicode first, to 2406 immediately catch any encoding issues and ensure internal unicode 2407 representation. 2408 2409 .. change:: 2410 :tags: 2411 :tickets: 2412 2413 added module_filename argument to Template to allow specification of a 2414 specific module file 2415 2416 .. change:: 2417 :tags: 2418 :tickets: 14 2419 2420 added modulename_callable to TemplateLookup to allow a function to 2421 determine module filenames (takes filename, uri arguments). used for 2422 2423 .. change:: 2424 :tags: 2425 :tickets: 2426 2427 added optional input_encoding flag to Template, to allow sending a 2428 unicode() object with no magic encoding comment 2429 2430 .. change:: 2431 :tags: 2432 :tickets: 2433 2434 "expression_filter" argument in <%page> applies only to expressions 2435 2436 .. change:: 2437 :tags: "unicode" 2438 :tickets: 2439 2440 added "default_filters" argument to Template, TemplateLookup. applies only 2441 to expressions, gets prepended to "expression_filter" arg from <%page>. 2442 defaults to, so that all expressions get stringified into u'' 2443 by default (this is what Mako already does). By setting to [], expressions 2444 are passed through raw. 2445 2446 .. change:: 2447 :tags: 2448 :tickets: 2449 2450 added "imports" argument to Template, TemplateLookup. so you can predefine 2451 a list of import statements at the top of the template. can be used in 2452 conjunction with default_filters. 2453 2454 .. change:: 2455 :tags: 2456 :tickets: 16 2457 2458 support for CRLF templates...whoops ! welcome to all the windows users. 2459 2460 .. change:: 2461 :tags: 2462 :tickets: 2463 2464 small fix to local variable propigation for locals that are conditionally 2465 declared 2466 2467 .. change:: 2468 :tags: 2469 :tickets: 2470 2471 got "top level" def calls to work, i.e. template.get_def("somedef").render() 2472 2473.. changelog:: 2474 :version: 0.1.1 2475 :released: Sun Jan 14 2007 2476 2477 .. change:: 2478 :tags: 2479 :tickets: 8 2480 2481 buffet plugin supports string-based templates, allows ToscaWidgets to work 2482 2483 .. change:: 2484 :tags: 2485 :tickets: 2486 2487 AST parsing fixes: fixed TryExcept identifier parsing 2488 2489 .. change:: 2490 :tags: 2491 :tickets: 2492 2493 removed textmate tmbundle from contrib and into separate SVN location; 2494 windows users cant handle those files, setuptools not very good at 2495 "pruning" certain directories 2496 2497 .. change:: 2498 :tags: 2499 :tickets: 2500 2501 fix so that "cache_timeout" parameter is propigated 2502 2503 .. change:: 2504 :tags: 2505 :tickets: 2506 2507 fix to expression filters so that string conversion (actually unicode) 2508 properly occurs before filtering 2509 2510 .. change:: 2511 :tags: 2512 :tickets: 2513 2514 better error message when a lookup is attempted with a template that has no 2515 lookup 2516 2517 .. change:: 2518 :tags: 2519 :tickets: 2520 2521 implemented "module" attribute for namespace 2522 2523 .. change:: 2524 :tags: 2525 :tickets: 2526 2527 fix to code generation to correctly track multiple defs with the same name 2528 2529 .. change:: 2530 :tags: 2531 :tickets: 9 2532 2533 "directories" can be passed to TemplateLookup as a scalar in which case it 2534 gets converted to a list 2535