Attribute language template compiler
Project description
Overview
--------
Chameleon is a generic byte-code compiler for attribute template
languages; it supports macros, includes, interpolation and
internationalization.
The ``chameleon.core`` package implements a language parser API, the
byte-code compiler itself and abstract template classes. It should
only be used directly when implementing a language dialect.
Development
-----------
If you want to use the code directly from trunk (recommended only for
development and testing usage), provide ``chameleon.core==dev`` as your
dependency.
The code is maintained in a subversion repository::
svn://svn.repoze.org/svn/chameleon.core
Want to contribute? Join #repoze on Freenode IRC.
Changelog
=========
1.0b33 (released 20/05/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Changes:
- Template arguments are now always passed in through the dynamic
variable scope (``econtext``). This change means that the
compilation signature now only depends on variables that are known
upon instantiation.
- Output is now always unicode, regardless of the encoding. This means
that input will be converted to unicode as required, while the
application must itself take care of the final conversion.
- Filled macro slots are now passed explicitly into the ``slots``
parameter, providing a formal API for rendering a macro. This
mechanism was not open previously, relying on low-level machinery to
function. As a technical aside, this change means that the provided
slots are no longer part of the compilation signature, which could
potentially reduce warm-up time.
Improvements:
- Added "strict" mode which currently acts as a flag to require filled
macro slots to be defined in the macro that's being used.
- Added test case for cancelation of attributes via a false value.
[hannosch]
- Optimized "Assign" clause when used with single join
statements. [hannosch]
- The required number of function calls needed for a rendering has
been reduced.
- A default encoding can be defined on the template class; only if an
explicit encoding is provided when instantiating a template will it
be overriden.
- The file cache now relies on the standard module import routines to
generate byte-code. When the file cache is enabled, a Python
source-file is added next to the template file (with the '.py'
filename extension).
Bugfixes:
- Fixed issue where a repeat through blocks that should be omitted
would generate unwanted whitespace. [malthe]
- Fixed issue where you could not use the variable name ``type`` since
it would collide with the builtin method, which was used
internally.
- Fixed incorrect variable name when reporting mismatched Python
versions in the cache pickles. [davisagli]
- Fixed minor issues with the ``default`` symbol; it now defaults to
``None``, if no default is available.
- Fixed an UnboundLocalError that occurred when attempting to load a
truncated cache file. [shane]
- Buildout configuration no longer depends on lxml. [shane]
1.0b32 (released 24/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Dropped dependency on ``lxml``. [malthe]
1.0b31 (released 22/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Correctly implement METAL 1.1 specification with regards to
``use-macro`` and ``extend-macro``, the difference being whether
slots are carried forward by default. To this effect, a key-error is
now being raised if a slot is attempted to be carried forward
without explicit redefinition. LP #364233. [malthe]
- Added ``validate``-method to the parser class; it will be called for
each parsed element, providing an option to raise language-level
exceptions during parsing. [malthe]
- Add support for ``metal:extend-macro``, even if it's basically an
alias for use-macro for now. [sidnei]
- Parse internal entities defined in <!DOCTYPE> and pass them around
to output, working around a bug in lxml. [sidnei]
1.0b30 (released 17/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``omit_default_prefix`` argument to template class; by default
this is enabled, such that attributes belonging to the same
namespace as the tag are printed without prefix. Certain legacy
applications require a prefix on all attributes however. [malthe]
1.0b29 (released 17/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where a limit was put on the total length of XML
namespace declarations by ``lxml``. [malthe]
- Exclude "transient symbols", defined as those who evaluate the
``chameleon.core.config.TRANSIENT_SYMBOL``. [malthe]
1.0b28 (released 08/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Initialize macros-object immediately after parsing for
efficiency. [malthe]
- Attempt at sniffing the content_type and encoding from the source
file, like zope.pagetemplate.pagetemplatefile does. [sidnei]
1.0b27 (released 06/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where nested variable definitions would not correctly
get restored, when doubly (or more) nested. [malthe]
- Use 'xmlcharrefreplace' sub-encoding when encoding output in
utils.attribute() [sidnei]
1.0b26 (released 01/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Worked around critical vulnerability in the built-in ``expat``
parser module that would cause a segmentation fault when parsing
certain unicode characters. [malthe]
- Add the internal symbol set to the first template scope; symbols in
this scope will never be passed when filling macro slots (this
supports a requirement in ZPT to keep a reference to the current
template instance, which should never be carried over). [malthe]
1.0b25 (released 31/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Use the 'xmlcharrefreplace' sub-encoding to ensure that non
unicode-compatible encodings are handled correctly. [malthe]
- Preserve HTML entities in output. See LP #350042. [malthe]
- Respect ordering of static attributes and apply also to dynamic
attributes. [malthe]
- Protect import of cache created with other Python-version. [malthe]
- Do not escape double quotes outside of attributes. LP
#348743. [malthe]
1.0b24 (released 23/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- When translating a section with unnamed blocks using a message id,
include contained elements as-is (without processing). [malthe]
- Catch type errors when loading template from cache. [malthe]
- Fixed issue where translating an element containing unnamed (missing
an i18n:name attribute) subelements would cause broken output. It's
now attempted to translate unnamed elements as-is (after processing,
as straight HTML), although ill-advised. LP #335937. [malthe]
- Fixed issue where concatenated output would sometimes fail due to
incorrect type checking. [malthe]
- Fixed bug where attributes from one of the default namespaces (those
defined by the engine and which do not require explicit definition
in the template). LP #340234. [malthe]
1.0b23 (released 13/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``get`` method to repeat dictionary. [malthe]
- Avoid infinite loop when using nested macros. [sidnei, malthe]
- When computing generator in repeat dictionary, swallow only
type-errors. [malthe]
- When accessing the ``macros`` attribute, make sure compiler is reset
when ``auto_reload`` is true and the source file has been
modified. [malthe]
- Check attribute namespace against element namespace, instead of
checking prefix. [sidnei]
1.0b22 (released 09/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Do not reset a dynamic scope which is being passed in as a
parameter. [malthe]
- Fixed bug where code in exception handlers would not get correctly
transformed. [malthe]
1.0b21 (released 05/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Repeating over ``None`` is same as repeating over empty tuple. [malthe]
- Added support for dynamic defaults. [malthe]
- Parts may now prescribe which exceptions to allow (default is any). [malthe]
- Added support for 'default' to fallback to default static content. [malthe]
1.0b20 (released 27/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Revamped template exceptions formatting. Argument values are now
presented briefly, rather than fully. [malthe]
1.0b19 (released 22/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added slight optimization to code transformer to avoid a second call
on the dynamic scope object. [malthe]
- Fixed bug where variable definition scope would not be
honored. [malthe]
1.0b18 (released 19/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for cancelling an escape by offering a ``__html__``
method. [malthe]
- Fixed issue where namespace prefix would not be recognized if
defined below another namespace definition. [malthe]
- Simplifed escaping routine; we only care about the classic three
entities. [malthe]
- Escape default translation content. [malthe]
- Translation of ``None`` should return ``None``. [malthe]
- Omit the element that defines a slot, if it's filled. [malthe]
1.0b17 (released 13/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Use ``tempfile.mkstemp`` to better garden temporary files. [malthe]
- Fixed issue where ``auto_reload`` would have no effect. [malthe]
- In debug-mode, source code is now written to disk, enabling us to
load (compile) it with ``imp.load_source`` instead of ``exec. This
allows pdb to step into the source code just like any other
file-based module. [malthe]
1.0b16 (released 12/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Parse templates only when needed, unless the environment variable
'CHAMELEON_EAGER' is set. [malthe]
- Correctly report back if the document is empty. [malthe]
- Fixed bug that prevented the parsing of XML fragments if they were
separated by comments. [malthe]
- Improved feedback on XML parsing errors. [malthe]
1.0b15 (released 29/01/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where attributes would be included for a foreign
namespace even though they were not part of that namespace. [malthe]
- Include (render) "foreign" namespace definitions in macros. [malthe]
- Support macro definitions on elements with METAL prefix. [malthe]
- Comments outside the root element get ignored (LP #317893). [sidnei]
- Set the template as __traceback_info__ in render_template, so that
for Zope 2/3 it shows up whenever an exception happens, making it
easier to diagnose what's the failing template in cases where many
templates and macros are being used to render a page. [sidnei]
- Verify that macros exist when accessed using the
dictionary-interface of the ``Macros`` object (LP #317572). [malthe]
- Restructured compilation step such that templates are always parsed
on source write, instead of 'just-in-time' before compilation. This
will enable us to query the parsed template separately from
compilation. [malthe]
- Added ``pass`` statement to guarantee valid block
structure (LP #312597). [malthe]
- Raise ``KeyError`` instead of ``ValueError`` when a macro cannot be
found. [malthe]
- Removed Zope security configuration. [malthe]
- Do not depend on component configuration. [malthe]
- Make tests pass under Python 2.4 [chrism]
1.0b14 (released 18/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Changed a try-except-finally construct into two nested try-except
clause to retain Python 2.4 compatibility. [cguardia]
1.0b13 (released 15/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed handling of static attributes on foreign elements. [malthe]
- Handle the case where the XML declaration does not have an
encoding. [malthe]
- Introduced new environment flag 'CHAMELEON_SOURCE' which determines
whether the source-code should be written to disk before
compilation. [malthe]
- Ignore comments that appear before a root element. [malthe]
- Issue a better error message if the expat parser has not been
properly initialized. [malthe]
- Merge adjacent strings in write-method. [malthe]
- Added version-control to file cache. This facilitates cache
invalidation on package upgrades. [malthe]
- Don't flush writes manually; instead, make sure all writes use the
`out` method and flush whenever `write` is used. This should prevent
consecutive writes (grouping them into one, instead). [malthe]
- Removed support for selectors bound to elements at compile-time. The
motivation for this functionality was to implement Genshi match
templates, however, incorrectly as it turns out. [malthe]
1.0b12 (released 03/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Support template fragments, e.g. documents with more than one
root element. [malthe]
- Added namespace prefix 'xml' to default namespace mapping. [malthe]
- Fixed root cause of issue with self-closing tags; an empty element
text is now correctly differentiated from a self-closed
tag (which does not have this attribute set). [malthe]
- Removed support for compilation without ``lxml``. [malthe]
- Use ``xml.parsers.expat`` to parse template document instead of
using ``lxml``. This gives much greater control over edge-cases and
allows us to lose many workarounds. [malthe]
- Do not use XPath-expressions during compilation if lxml is not
available. [malthe]
- Ensure argument uniqueness for macro functions over the combined set of
scope and keyword arguments. [hannosch]
- Protect all `itertools.chain` statements with an encapsulating set() to
ensure uniqueness. [hannosch]
1.0b11 (released 29/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Ensure that function arguments passed into macros are unique. [hannosch]
- Removed unused imports, thanks to PyFlakes. [hannosch]
- Removed warning about utf-8 as a recommend default encoding. There is no
apparent speed improvement anymore. [hannosch]
- Use ``sourcecodegen`` package to generate Python-code from AST; this
is done to avoid generating code using the ``compiler.pycodegen``
module, which has serious issues. Interestingly, this approach cuts
compilation time in half. [malthe]
- Bind code-generation utilities in closure as well. [malthe]
- Reworked global scope initialization; we now bind these using a
closure. [malthe]
- Reworked repeat-variable logic. An iterator would be realized at any
rate, so let's not try to be clever. [malthe]
- Made repeat-variable work with iterables which do not announce their
length before execution. [malthe]
- Added namespace attribute support. [malthe]
- Static attributes are now computed such that attributes are omitted
according to a `ns_omit` flag, and they are always prefixed
according to the element's `nsmap`. [malthe]
- Do not fix-up self-closing tags if an XML declaration is present
without a DOCTYPE. [malthe]
- Prefix tags which do not belong to the default namespace. [malthe]
1.0b10 (released 24/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Do not apply namespace attribute 'xmlns' to root element if not
set. [malthe]
- Fixed tuple unpacking in repeat loops. [malthe]
- Use a custom simple BufferIO class for the lxml.etree parser instead of
standard StringIO. [hannosch]
- This was the wrong fix, however; what needed to be changed is that
the class of the marker isntance must be available at
module-scope. [malthe]
- Changed generation.marker back to a normal object instance. Otherwise we get
PicklingError: Can't pickle <class 'chameleon.core.generation.marker'>:
it's not the same object as chameleon.core.generation.marker. [hannosch]
- Changed two isinstance checks to check for basestring instead of str or
unicode. [hannosch]
1.0b9 (released 19/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``label`` property to expressions; this allows providing a
human-readable label for values that are going to
evaluated. [malthe]
- Normalize METAL slot names to ensure they're valid Python variable
names. Non-valid characters are converted to underscore. [malthe]
- Renamed dynamic scope variable to `econtext` in order to reduce
compatibility issues with ZPT. [malthe]
- Fixed issue where multiple defines would cause integrity
issues. [malthe]
- Avoid self-closing tags that are not allowed in transitional
HTML. [malthe]
- Use custom serialization method to serialize static default
translation blocks; we can't rely on `lxml` for sane
output. [malthe]
- Make `default` symbol available to dynamic attribute
evaluations. [malthe]
- Visit evaluation before assignment in order to support assignments
that rely on the same name in the dynamic variable scope. [malthe]
- Conditions may now be inverted; this facilitates the bug-fix of an
issue where omit conditions were multi-part. [malthe]
- Make sure that arguments passed into the `render`-method are
introduced in every nested scope. [malthe]
- Added translation language to main scope and make sure redefining it
inside a closure does not cause issues with nested scope
locals. [malthe]
1.0b8 (released 16/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Only pretend to delete variables; this improves performance and
guarantees that we don't attempt to delete a variables which is used
in a nested scope (closure). It works, because the code generation
transform silently drops the delete-statements, but removes them
from its internal scope dictionary. [malthe]
- Remove variables from scope dictionary upon block exit. [malthe]
- Split out compile-function such that we can always write the source
code to disk in debug-mode. [malthe]
- Correctly transfer scope to callback-function that will fill macro
slot contents. Previously, we would precompute fill-slots, but this
was wrong since it's expected to inherit the scope of the macro
currently in use. [malthe]
- Made error handler compatible with Python 2.4 [malthe]
- Maintain symbol mappings for joined expressions. [malthe]
1.0b7 (released 15/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed interpolation edge where a right curly brace not part of an
interpolation expression would cancel a succeeding
interpolation. [malthe]
- Pass `target_language` when using macros. [malthe]
1.0b6 (released 13/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- When validating inserted content (in debug-mode), make sure we wrap
content as a proper HTML document, including HTML entity
definitions. [malthe]
- If an element does not belong to a known namespace, assume it's the
default namespace. This change is relevant after the introduction of
fallback elements. [malthe]
- XML declarations should be printed with or without a doctype
element, and only if the template includes it. [malthe]
1.0b5 (released 12/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Encode code annotations if encoding is required. [malthe]
- Added filename to XML syntax error exception message. [malthe]
- Fixed bug where a template would be wrapped with namespace
definitions even if an XML header is present. [malthe]
- Added support for fallback element. [malthe]
- Enabled error handler for macro renderer. [malthe]
- Added error handler which adds debugging information to the
exception object's string output (in debug-mode only). [malthe]
1.0b4 (released 28/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed translation issues (see recently added tests). [malthe]
- Refactored string coercion. [malthe]
1.0b3 (released 13/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue with parsing expression containing curly
braces. [malthe]
- Added support for unscoped variable assignment. [malthe]
1.0b2 (released 11/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for translating dynamic body text (used in
interpolation expressions). [malthe]
- Added support for macros prebound to keyword arguments. [malthe]
1.0b1 (released 2/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed bugs related to temporary variables with loops and
conditions. [malthe]
- Set default value for `auto-reload` based on the CHAMELEON_DEBUG
environment variable check. [malthe]
1.0a4 (released 9/29/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added method to generate unscoped temporary variables. [malthe]
- Make lxml a hard dependency for now until the lxml-less logic is stable.
[wichert]
1.0a3 (released 9/26/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- TemplateLoader now checks a default_parser class attribute if no
parser is specified. [wichert]
1.0a2 (released 9/26/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for dynamic skip condition. [malthe]
- Fixed bug where an AttributeError would be raised when using the
file cache. [malthe]
1.0a1 (released 9/24/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- First release.
--------
Chameleon is a generic byte-code compiler for attribute template
languages; it supports macros, includes, interpolation and
internationalization.
The ``chameleon.core`` package implements a language parser API, the
byte-code compiler itself and abstract template classes. It should
only be used directly when implementing a language dialect.
Development
-----------
If you want to use the code directly from trunk (recommended only for
development and testing usage), provide ``chameleon.core==dev`` as your
dependency.
The code is maintained in a subversion repository::
svn://svn.repoze.org/svn/chameleon.core
Want to contribute? Join #repoze on Freenode IRC.
Changelog
=========
1.0b33 (released 20/05/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Changes:
- Template arguments are now always passed in through the dynamic
variable scope (``econtext``). This change means that the
compilation signature now only depends on variables that are known
upon instantiation.
- Output is now always unicode, regardless of the encoding. This means
that input will be converted to unicode as required, while the
application must itself take care of the final conversion.
- Filled macro slots are now passed explicitly into the ``slots``
parameter, providing a formal API for rendering a macro. This
mechanism was not open previously, relying on low-level machinery to
function. As a technical aside, this change means that the provided
slots are no longer part of the compilation signature, which could
potentially reduce warm-up time.
Improvements:
- Added "strict" mode which currently acts as a flag to require filled
macro slots to be defined in the macro that's being used.
- Added test case for cancelation of attributes via a false value.
[hannosch]
- Optimized "Assign" clause when used with single join
statements. [hannosch]
- The required number of function calls needed for a rendering has
been reduced.
- A default encoding can be defined on the template class; only if an
explicit encoding is provided when instantiating a template will it
be overriden.
- The file cache now relies on the standard module import routines to
generate byte-code. When the file cache is enabled, a Python
source-file is added next to the template file (with the '.py'
filename extension).
Bugfixes:
- Fixed issue where a repeat through blocks that should be omitted
would generate unwanted whitespace. [malthe]
- Fixed issue where you could not use the variable name ``type`` since
it would collide with the builtin method, which was used
internally.
- Fixed incorrect variable name when reporting mismatched Python
versions in the cache pickles. [davisagli]
- Fixed minor issues with the ``default`` symbol; it now defaults to
``None``, if no default is available.
- Fixed an UnboundLocalError that occurred when attempting to load a
truncated cache file. [shane]
- Buildout configuration no longer depends on lxml. [shane]
1.0b32 (released 24/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Dropped dependency on ``lxml``. [malthe]
1.0b31 (released 22/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Correctly implement METAL 1.1 specification with regards to
``use-macro`` and ``extend-macro``, the difference being whether
slots are carried forward by default. To this effect, a key-error is
now being raised if a slot is attempted to be carried forward
without explicit redefinition. LP #364233. [malthe]
- Added ``validate``-method to the parser class; it will be called for
each parsed element, providing an option to raise language-level
exceptions during parsing. [malthe]
- Add support for ``metal:extend-macro``, even if it's basically an
alias for use-macro for now. [sidnei]
- Parse internal entities defined in <!DOCTYPE> and pass them around
to output, working around a bug in lxml. [sidnei]
1.0b30 (released 17/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``omit_default_prefix`` argument to template class; by default
this is enabled, such that attributes belonging to the same
namespace as the tag are printed without prefix. Certain legacy
applications require a prefix on all attributes however. [malthe]
1.0b29 (released 17/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where a limit was put on the total length of XML
namespace declarations by ``lxml``. [malthe]
- Exclude "transient symbols", defined as those who evaluate the
``chameleon.core.config.TRANSIENT_SYMBOL``. [malthe]
1.0b28 (released 08/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Initialize macros-object immediately after parsing for
efficiency. [malthe]
- Attempt at sniffing the content_type and encoding from the source
file, like zope.pagetemplate.pagetemplatefile does. [sidnei]
1.0b27 (released 06/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where nested variable definitions would not correctly
get restored, when doubly (or more) nested. [malthe]
- Use 'xmlcharrefreplace' sub-encoding when encoding output in
utils.attribute() [sidnei]
1.0b26 (released 01/04/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Worked around critical vulnerability in the built-in ``expat``
parser module that would cause a segmentation fault when parsing
certain unicode characters. [malthe]
- Add the internal symbol set to the first template scope; symbols in
this scope will never be passed when filling macro slots (this
supports a requirement in ZPT to keep a reference to the current
template instance, which should never be carried over). [malthe]
1.0b25 (released 31/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Use the 'xmlcharrefreplace' sub-encoding to ensure that non
unicode-compatible encodings are handled correctly. [malthe]
- Preserve HTML entities in output. See LP #350042. [malthe]
- Respect ordering of static attributes and apply also to dynamic
attributes. [malthe]
- Protect import of cache created with other Python-version. [malthe]
- Do not escape double quotes outside of attributes. LP
#348743. [malthe]
1.0b24 (released 23/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- When translating a section with unnamed blocks using a message id,
include contained elements as-is (without processing). [malthe]
- Catch type errors when loading template from cache. [malthe]
- Fixed issue where translating an element containing unnamed (missing
an i18n:name attribute) subelements would cause broken output. It's
now attempted to translate unnamed elements as-is (after processing,
as straight HTML), although ill-advised. LP #335937. [malthe]
- Fixed issue where concatenated output would sometimes fail due to
incorrect type checking. [malthe]
- Fixed bug where attributes from one of the default namespaces (those
defined by the engine and which do not require explicit definition
in the template). LP #340234. [malthe]
1.0b23 (released 13/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``get`` method to repeat dictionary. [malthe]
- Avoid infinite loop when using nested macros. [sidnei, malthe]
- When computing generator in repeat dictionary, swallow only
type-errors. [malthe]
- When accessing the ``macros`` attribute, make sure compiler is reset
when ``auto_reload`` is true and the source file has been
modified. [malthe]
- Check attribute namespace against element namespace, instead of
checking prefix. [sidnei]
1.0b22 (released 09/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Do not reset a dynamic scope which is being passed in as a
parameter. [malthe]
- Fixed bug where code in exception handlers would not get correctly
transformed. [malthe]
1.0b21 (released 05/03/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Repeating over ``None`` is same as repeating over empty tuple. [malthe]
- Added support for dynamic defaults. [malthe]
- Parts may now prescribe which exceptions to allow (default is any). [malthe]
- Added support for 'default' to fallback to default static content. [malthe]
1.0b20 (released 27/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Revamped template exceptions formatting. Argument values are now
presented briefly, rather than fully. [malthe]
1.0b19 (released 22/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added slight optimization to code transformer to avoid a second call
on the dynamic scope object. [malthe]
- Fixed bug where variable definition scope would not be
honored. [malthe]
1.0b18 (released 19/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for cancelling an escape by offering a ``__html__``
method. [malthe]
- Fixed issue where namespace prefix would not be recognized if
defined below another namespace definition. [malthe]
- Simplifed escaping routine; we only care about the classic three
entities. [malthe]
- Escape default translation content. [malthe]
- Translation of ``None`` should return ``None``. [malthe]
- Omit the element that defines a slot, if it's filled. [malthe]
1.0b17 (released 13/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Use ``tempfile.mkstemp`` to better garden temporary files. [malthe]
- Fixed issue where ``auto_reload`` would have no effect. [malthe]
- In debug-mode, source code is now written to disk, enabling us to
load (compile) it with ``imp.load_source`` instead of ``exec. This
allows pdb to step into the source code just like any other
file-based module. [malthe]
1.0b16 (released 12/02/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Parse templates only when needed, unless the environment variable
'CHAMELEON_EAGER' is set. [malthe]
- Correctly report back if the document is empty. [malthe]
- Fixed bug that prevented the parsing of XML fragments if they were
separated by comments. [malthe]
- Improved feedback on XML parsing errors. [malthe]
1.0b15 (released 29/01/2009)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue where attributes would be included for a foreign
namespace even though they were not part of that namespace. [malthe]
- Include (render) "foreign" namespace definitions in macros. [malthe]
- Support macro definitions on elements with METAL prefix. [malthe]
- Comments outside the root element get ignored (LP #317893). [sidnei]
- Set the template as __traceback_info__ in render_template, so that
for Zope 2/3 it shows up whenever an exception happens, making it
easier to diagnose what's the failing template in cases where many
templates and macros are being used to render a page. [sidnei]
- Verify that macros exist when accessed using the
dictionary-interface of the ``Macros`` object (LP #317572). [malthe]
- Restructured compilation step such that templates are always parsed
on source write, instead of 'just-in-time' before compilation. This
will enable us to query the parsed template separately from
compilation. [malthe]
- Added ``pass`` statement to guarantee valid block
structure (LP #312597). [malthe]
- Raise ``KeyError`` instead of ``ValueError`` when a macro cannot be
found. [malthe]
- Removed Zope security configuration. [malthe]
- Do not depend on component configuration. [malthe]
- Make tests pass under Python 2.4 [chrism]
1.0b14 (released 18/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Changed a try-except-finally construct into two nested try-except
clause to retain Python 2.4 compatibility. [cguardia]
1.0b13 (released 15/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed handling of static attributes on foreign elements. [malthe]
- Handle the case where the XML declaration does not have an
encoding. [malthe]
- Introduced new environment flag 'CHAMELEON_SOURCE' which determines
whether the source-code should be written to disk before
compilation. [malthe]
- Ignore comments that appear before a root element. [malthe]
- Issue a better error message if the expat parser has not been
properly initialized. [malthe]
- Merge adjacent strings in write-method. [malthe]
- Added version-control to file cache. This facilitates cache
invalidation on package upgrades. [malthe]
- Don't flush writes manually; instead, make sure all writes use the
`out` method and flush whenever `write` is used. This should prevent
consecutive writes (grouping them into one, instead). [malthe]
- Removed support for selectors bound to elements at compile-time. The
motivation for this functionality was to implement Genshi match
templates, however, incorrectly as it turns out. [malthe]
1.0b12 (released 03/12/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Support template fragments, e.g. documents with more than one
root element. [malthe]
- Added namespace prefix 'xml' to default namespace mapping. [malthe]
- Fixed root cause of issue with self-closing tags; an empty element
text is now correctly differentiated from a self-closed
tag (which does not have this attribute set). [malthe]
- Removed support for compilation without ``lxml``. [malthe]
- Use ``xml.parsers.expat`` to parse template document instead of
using ``lxml``. This gives much greater control over edge-cases and
allows us to lose many workarounds. [malthe]
- Do not use XPath-expressions during compilation if lxml is not
available. [malthe]
- Ensure argument uniqueness for macro functions over the combined set of
scope and keyword arguments. [hannosch]
- Protect all `itertools.chain` statements with an encapsulating set() to
ensure uniqueness. [hannosch]
1.0b11 (released 29/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Ensure that function arguments passed into macros are unique. [hannosch]
- Removed unused imports, thanks to PyFlakes. [hannosch]
- Removed warning about utf-8 as a recommend default encoding. There is no
apparent speed improvement anymore. [hannosch]
- Use ``sourcecodegen`` package to generate Python-code from AST; this
is done to avoid generating code using the ``compiler.pycodegen``
module, which has serious issues. Interestingly, this approach cuts
compilation time in half. [malthe]
- Bind code-generation utilities in closure as well. [malthe]
- Reworked global scope initialization; we now bind these using a
closure. [malthe]
- Reworked repeat-variable logic. An iterator would be realized at any
rate, so let's not try to be clever. [malthe]
- Made repeat-variable work with iterables which do not announce their
length before execution. [malthe]
- Added namespace attribute support. [malthe]
- Static attributes are now computed such that attributes are omitted
according to a `ns_omit` flag, and they are always prefixed
according to the element's `nsmap`. [malthe]
- Do not fix-up self-closing tags if an XML declaration is present
without a DOCTYPE. [malthe]
- Prefix tags which do not belong to the default namespace. [malthe]
1.0b10 (released 24/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Do not apply namespace attribute 'xmlns' to root element if not
set. [malthe]
- Fixed tuple unpacking in repeat loops. [malthe]
- Use a custom simple BufferIO class for the lxml.etree parser instead of
standard StringIO. [hannosch]
- This was the wrong fix, however; what needed to be changed is that
the class of the marker isntance must be available at
module-scope. [malthe]
- Changed generation.marker back to a normal object instance. Otherwise we get
PicklingError: Can't pickle <class 'chameleon.core.generation.marker'>:
it's not the same object as chameleon.core.generation.marker. [hannosch]
- Changed two isinstance checks to check for basestring instead of str or
unicode. [hannosch]
1.0b9 (released 19/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``label`` property to expressions; this allows providing a
human-readable label for values that are going to
evaluated. [malthe]
- Normalize METAL slot names to ensure they're valid Python variable
names. Non-valid characters are converted to underscore. [malthe]
- Renamed dynamic scope variable to `econtext` in order to reduce
compatibility issues with ZPT. [malthe]
- Fixed issue where multiple defines would cause integrity
issues. [malthe]
- Avoid self-closing tags that are not allowed in transitional
HTML. [malthe]
- Use custom serialization method to serialize static default
translation blocks; we can't rely on `lxml` for sane
output. [malthe]
- Make `default` symbol available to dynamic attribute
evaluations. [malthe]
- Visit evaluation before assignment in order to support assignments
that rely on the same name in the dynamic variable scope. [malthe]
- Conditions may now be inverted; this facilitates the bug-fix of an
issue where omit conditions were multi-part. [malthe]
- Make sure that arguments passed into the `render`-method are
introduced in every nested scope. [malthe]
- Added translation language to main scope and make sure redefining it
inside a closure does not cause issues with nested scope
locals. [malthe]
1.0b8 (released 16/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Only pretend to delete variables; this improves performance and
guarantees that we don't attempt to delete a variables which is used
in a nested scope (closure). It works, because the code generation
transform silently drops the delete-statements, but removes them
from its internal scope dictionary. [malthe]
- Remove variables from scope dictionary upon block exit. [malthe]
- Split out compile-function such that we can always write the source
code to disk in debug-mode. [malthe]
- Correctly transfer scope to callback-function that will fill macro
slot contents. Previously, we would precompute fill-slots, but this
was wrong since it's expected to inherit the scope of the macro
currently in use. [malthe]
- Made error handler compatible with Python 2.4 [malthe]
- Maintain symbol mappings for joined expressions. [malthe]
1.0b7 (released 15/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed interpolation edge where a right curly brace not part of an
interpolation expression would cancel a succeeding
interpolation. [malthe]
- Pass `target_language` when using macros. [malthe]
1.0b6 (released 13/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- When validating inserted content (in debug-mode), make sure we wrap
content as a proper HTML document, including HTML entity
definitions. [malthe]
- If an element does not belong to a known namespace, assume it's the
default namespace. This change is relevant after the introduction of
fallback elements. [malthe]
- XML declarations should be printed with or without a doctype
element, and only if the template includes it. [malthe]
1.0b5 (released 12/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Encode code annotations if encoding is required. [malthe]
- Added filename to XML syntax error exception message. [malthe]
- Fixed bug where a template would be wrapped with namespace
definitions even if an XML header is present. [malthe]
- Added support for fallback element. [malthe]
- Enabled error handler for macro renderer. [malthe]
- Added error handler which adds debugging information to the
exception object's string output (in debug-mode only). [malthe]
1.0b4 (released 28/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed translation issues (see recently added tests). [malthe]
- Refactored string coercion. [malthe]
1.0b3 (released 13/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed issue with parsing expression containing curly
braces. [malthe]
- Added support for unscoped variable assignment. [malthe]
1.0b2 (released 11/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for translating dynamic body text (used in
interpolation expressions). [malthe]
- Added support for macros prebound to keyword arguments. [malthe]
1.0b1 (released 2/10/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed bugs related to temporary variables with loops and
conditions. [malthe]
- Set default value for `auto-reload` based on the CHAMELEON_DEBUG
environment variable check. [malthe]
1.0a4 (released 9/29/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added method to generate unscoped temporary variables. [malthe]
- Make lxml a hard dependency for now until the lxml-less logic is stable.
[wichert]
1.0a3 (released 9/26/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- TemplateLoader now checks a default_parser class attribute if no
parser is specified. [wichert]
1.0a2 (released 9/26/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added support for dynamic skip condition. [malthe]
- Fixed bug where an AttributeError would be raised when using the
file cache. [malthe]
1.0a1 (released 9/24/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- First release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chameleon.core-1.0b33.tar.gz
(61.6 kB
view hashes)