Skip to main content

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.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


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.0b14.tar.gz (44.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page