cmlenz@233: Upgrading Genshi cmlenz@233: ================ cmlenz@233: cmlenz@606: cmlenz@606: .. contents:: Contents cmlenz@606: :depth: 2 cmlenz@606: .. sectnum:: cmlenz@606: cmlenz@606: cmlenz@592: Upgrading from Genshi 0.4.x to 0.5.x cmlenz@592: ------------------------------------ cmlenz@592: cmlenz@606: Genshi 0.5 introduces a new, alternative syntax for text templates, cmlenz@606: which is more flexible and powerful compared to the old syntax. For cmlenz@606: backwards compatibility, this new syntax is not used by default, cmlenz@606: though it will be in a future version. It is recommended that you cmlenz@606: migrate to using this new syntax. To do so, simply rename any cmlenz@606: references in your code to ``TextTemplate`` to ``NewTextTemplate``. To cmlenz@606: explicitly use the old syntax, use ``OldTextTemplate`` instead, so cmlenz@606: that you can be sure you'll be using the same language when the cmlenz@592: default in Genshi is changed (at least until the old implementation is cmlenz@592: completely removed). cmlenz@592: cmlenz@606: The default error handling mode has been changed to "strict". This cmlenz@606: means that accessing variables not defined in the template data will cmlenz@606: now generate an immediate exception, as will accessing object cmlenz@606: attributes or dictionary keys that don't exist. If your templates rely cmlenz@606: on the old lenient behavior, you can configure Genshi to use that cmlenz@606: instead. See the documentation for details on how to do that. But be cmlenz@606: warned that lenient error handling may be removed completely in a cmlenz@606: future release. cmlenz@606: cmlenz@592: cmlenz@336: Upgrading from Genshi 0.3.x to 0.4.x cmlenz@336: ------------------------------------ cmlenz@336: cmlenz@452: The modules ``genshi.filters`` and ``genshi.template`` have been cmlenz@452: refactored into packages containing multiple modules. While code using cmlenz@452: the regular APIs should continue to work without problems, you should cmlenz@606: make sure to remove any leftover traces of the files ``filters.py`` cmlenz@606: and ``template.py`` in the ``genshi`` package on the installation cmlenz@606: path (including the corresponding ``.pyc`` files). This is not cmlenz@606: necessary when Genshi was installed as a Python egg. cmlenz@336: cmlenz@343: Results of evaluating template expressions are no longer implicitly cmlenz@343: called if they are callable. If you have been using that feature, you cmlenz@343: will need to add the parenthesis to actually call the function. cmlenz@343: cmlenz@606: Instances of ``genshi.core.Attrs`` are now immutable. Filters cmlenz@411: manipulating the attributes in a stream may need to be updated. Also, cmlenz@606: the ``Attrs`` class no longer automatically wraps all attribute names cmlenz@606: in ``QName`` objects, so users of the ``Attrs`` class need to do this cmlenz@606: themselves. See the documentation of the ``Attrs`` class for more cmlenz@411: information. cmlenz@411: cmlenz@345: cmlenz@233: Upgrading from Markup cmlenz@233: --------------------- cmlenz@233: cmlenz@233: Prior to version 0.3, the name of the Genshi project was "Markup". The cmlenz@233: name change means that you will have to adjust your import statements cmlenz@233: and the namespace URI of XML templates, among other things: cmlenz@233: cmlenz@606: * The package name was changed from "markup" to "genshi". Please cmlenz@606: adjust any import statements referring to the old package name. cmlenz@606: * The namespace URI for directives in Genshi XML templates has changed cmlenz@606: from ``http://markup.edgewall.org/`` to cmlenz@606: ``http://genshi.edgewall.org/``. Please update the ``xmlns:py`` cmlenz@606: declaration in your template files accordingly. cmlenz@233: cmlenz@233: Furthermore, due to the inclusion of a text-based template language, cmlenz@606: the class:: cmlenz@233: cmlenz@606: markup.template.Template cmlenz@233: cmlenz@606: has been renamed to:: cmlenz@233: cmlenz@606: genshi.template.MarkupTemplate cmlenz@233: cmlenz@233: If you've been using the Template class directly, you'll need to cmlenz@606: update your code (a simple find/replace should do—the API itself cmlenz@233: did not change).