{"id":23011,"library":"z3c-pt","title":"z3c.pt","description":"Fast Zope Page Templates (ZPT) engine implementing TAL/TALES/METAL specifications. Version 5.1 requires Python >=3.9. Releases are stable and infrequent, focusing on maintenance.","status":"active","version":"5.1","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/z3c.pt","tags":["zpt","templates","tal","zope","python3"],"install":[{"cmd":"pip install z3c.pt","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"PageTemplate is a top-level API; importing from submodule is fragile and may break in future versions.","wrong":"from z3c.pt.page_template import PageTemplate","symbol":"PageTemplate","correct":"from z3c.pt import PageTemplate"},{"note":"getEngine is exposed at package level; internal module paths are not guaranteed.","wrong":"from z3c.pt.engine import getEngine","symbol":"getEngine","correct":"from z3c.pt import getEngine"}],"quickstart":{"code":"from z3c.pt import PageTemplate, getEngine\nengine = getEngine()\ntemplate = engine.compile('<html><body><p tal:content=\"message\"></p></body></html>')\n# For a simple render, use the template directly (requires context)\n# engine = engine  # no context needed for compile, but rendering needs dict\nresult = template({'message': 'Hello, world!'})\nprint(result)","lang":"python","description":"Compiles a ZPT template string and renders it with a context dictionary."},"warnings":[{"fix":"Update imports from e.g. `z3c.template` to `z3c.pt` and adjust API usage per current docs.","message":"In version 5.0, the package was split from `z3c.pt` standalone; previously it was part of `z3c.template`. If upgrading from older versions (pre-5.0), imports and API changed. Ensure you are using `z3c.pt` directly.","severity":"breaking","affected_versions":"<5.0"},{"fix":"Upgrade to Python 3.9 or later.","message":"The `z3c.pt` package now requires Python 3.9+. Python 2.7 and 3.5-3.8 are no longer supported.","severity":"deprecated","affected_versions":">=5.0"},{"fix":"Use simple Python expressions in TAL attributes, e.g., `tal:content=\"variable\"`.","message":"TAL expressions like `tal:content` expect Python expressions, not paths. A common mistake is using dotted paths like `tal:content=\"context/some\"` which is Zope-specific. For standalone use, provide a dict with keys as variable names.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install latest version: pip install --upgrade z3c.pt. Ensure you are using Python >=3.9.","cause":"Older version of z3c.pt (<5.0) might have different API, or package not installed correctly.","error":"ImportError: cannot import name 'PageTemplate' from 'z3c.pt'"},{"fix":"Call getEngine() at module level or before compiling templates: from z3c.pt import getEngine; engine = getEngine()","cause":"Engine not created before compiling templates. The default engine must be obtained via getEngine().","error":"RuntimeError: No engine configured"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}