Mercurial > genshi > genshi-test
comparison doc/upgrade.txt @ 820:1837f39efd6f experimental-inline
Sync (old) experimental inline branch with trunk@1027.
author | cmlenz |
---|---|
date | Wed, 11 Mar 2009 17:51:06 +0000 |
parents | |
children | 09cc3627654c |
comparison
equal
deleted
inserted
replaced
500:0742f421caba | 820:1837f39efd6f |
---|---|
1 ================ | |
2 Upgrading Genshi | |
3 ================ | |
4 | |
5 | |
6 .. contents:: Contents | |
7 :depth: 2 | |
8 .. sectnum:: | |
9 | |
10 | |
11 ------------------------------------ | |
12 Upgrading from Genshi 0.5.x to 0.6.x | |
13 ------------------------------------ | |
14 | |
15 Required Python Version | |
16 ----------------------- | |
17 | |
18 Support for Python 2.3 has been dropped in this release. Python 2.4 is | |
19 now the minimum version of Python required to run Genshi. | |
20 | |
21 | |
22 ------------------------------------ | |
23 Upgrading from Genshi 0.4.x to 0.5.x | |
24 ------------------------------------ | |
25 | |
26 Error Handling | |
27 -------------- | |
28 | |
29 The default error handling mode has been changed to "strict". This | |
30 means that accessing variables not defined in the template data will | |
31 now generate an immediate exception, as will accessing object | |
32 attributes or dictionary keys that don't exist. If your templates rely | |
33 on the old lenient behavior, you can configure Genshi to use that | |
34 instead. See the documentation for details on how to do that. But be | |
35 warned that lenient error handling may be removed completely in a | |
36 future release. | |
37 | |
38 Match Template Processing | |
39 ------------------------- | |
40 | |
41 There has also been a subtle change to how ``py:match`` templates are | |
42 processed: in previous versions, all match templates would be applied | |
43 to the content generated by the matching template, and only the | |
44 matching template itself was applied recursively to the original | |
45 content. This behavior resulted in problems with many kinds of | |
46 recursive matching, and hence was changed for 0.5: now, all match | |
47 templates declared before the matching template are applied to the | |
48 original content, and match templates declared after the matching | |
49 template are applied to the generated content. This change should not | |
50 have any effect on most applications, but you may want to check your | |
51 use of match templates to make sure. | |
52 | |
53 Text Templates | |
54 -------------- | |
55 | |
56 Genshi 0.5 introduces a new, alternative syntax for text templates, | |
57 which is more flexible and powerful compared to the old syntax. For | |
58 backwards compatibility, this new syntax is not used by default, | |
59 though it will be in a future version. It is recommended that you | |
60 migrate to using this new syntax. To do so, simply rename any | |
61 references in your code to ``TextTemplate`` to ``NewTextTemplate``. To | |
62 explicitly use the old syntax, use ``OldTextTemplate`` instead, so | |
63 that you can be sure you'll be using the same language when the | |
64 default in Genshi is changed (at least until the old implementation is | |
65 completely removed). | |
66 | |
67 ``Markup`` Constructor | |
68 ---------------------- | |
69 | |
70 The ``Markup`` class no longer has a specialized constructor. The old | |
71 (undocumented) constructor provided a shorthand for doing positional | |
72 substitutions. If you have code like this: | |
73 | |
74 .. code-block:: python | |
75 | |
76 Markup('<b>%s</b>', name) | |
77 | |
78 You must replace it by the more explicit: | |
79 | |
80 .. code-block:: python | |
81 | |
82 Markup('<b>%s</b>') % name | |
83 | |
84 ``Template`` Constructor | |
85 ------------------------ | |
86 | |
87 The constructor of the ``Template`` class and its subclasses has changed | |
88 slightly: instead of the optional ``basedir`` parameter, it now expects | |
89 an (also optional) ``filepath`` parameter, which specifies the absolute | |
90 path to the template. You probably aren't using those constructors | |
91 directly, anyway, but using the ``TemplateLoader`` API instead. | |
92 | |
93 | |
94 ------------------------------------ | |
95 Upgrading from Genshi 0.3.x to 0.4.x | |
96 ------------------------------------ | |
97 | |
98 The modules ``genshi.filters`` and ``genshi.template`` have been | |
99 refactored into packages containing multiple modules. While code using | |
100 the regular APIs should continue to work without problems, you should | |
101 make sure to remove any leftover traces of the files ``filters.py`` | |
102 and ``template.py`` in the ``genshi`` package on the installation | |
103 path (including the corresponding ``.pyc`` files). This is not | |
104 necessary when Genshi was installed as a Python egg. | |
105 | |
106 Results of evaluating template expressions are no longer implicitly | |
107 called if they are callable. If you have been using that feature, you | |
108 will need to add the parenthesis to actually call the function. | |
109 | |
110 Instances of ``genshi.core.Attrs`` are now immutable. Filters | |
111 manipulating the attributes in a stream may need to be updated. Also, | |
112 the ``Attrs`` class no longer automatically wraps all attribute names | |
113 in ``QName`` objects, so users of the ``Attrs`` class need to do this | |
114 themselves. See the documentation of the ``Attrs`` class for more | |
115 information. | |
116 | |
117 | |
118 --------------------- | |
119 Upgrading from Markup | |
120 --------------------- | |
121 | |
122 Prior to version 0.3, the name of the Genshi project was "Markup". The | |
123 name change means that you will have to adjust your import statements | |
124 and the namespace URI of XML templates, among other things: | |
125 | |
126 * The package name was changed from "markup" to "genshi". Please | |
127 adjust any import statements referring to the old package name. | |
128 * The namespace URI for directives in Genshi XML templates has changed | |
129 from ``http://markup.edgewall.org/`` to | |
130 ``http://genshi.edgewall.org/``. Please update the ``xmlns:py`` | |
131 declaration in your template files accordingly. | |
132 | |
133 Furthermore, due to the inclusion of a text-based template language, | |
134 the class:: | |
135 | |
136 markup.template.Template | |
137 | |
138 has been renamed to:: | |
139 | |
140 genshi.template.MarkupTemplate | |
141 | |
142 If you've been using the Template class directly, you'll need to | |
143 update your code (a simple find/replace should do—the API itself | |
144 did not change). |