{"id":27568,"library":"zope-ptresource","title":"zope.ptresource","description":"Page template resource plugin for zope.browserresource. Version 6.0 supports Python >=3.9. Provides a way to register page templates as browser resources using ZCML directives. Release cadence is low, maintained by Zope Foundation.","status":"active","version":"6.0","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/zope.ptresource/","tags":["zope","pagetemplate","resource"],"install":[{"cmd":"pip install zope.ptresource","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Core dependency; provides resource infrastructure","package":"zope.browserresource","optional":false},{"reason":"Required for page template parsing","package":"zope.pagetemplate","optional":false},{"reason":"Required for ZCML and component architecture","package":"zope.component","optional":false}],"imports":[{"note":"Direct use is rare; usually registered via ZCML.","wrong":null,"symbol":"PageTemplateResource","correct":"from zope.ptresource import PageTemplateResource"}],"quickstart":{"code":"# Example ZCML registration (configure.zcml)\n<configure xmlns=\"http://namespaces.zope.org/zope\">\n  <include package=\"zope.ptresource\" file=\"meta.zcml\" />\n  \n  <ptresource\n      name=\"my_template\"\n      template=\"my_template.pt\"\n      for=\"*\"\n      layer=\"default\"\n      />\n</configure>","lang":"python","description":"Register a page template resource using ZCML. The ptresource directive requires package='zope.ptresource' to be included first."},"warnings":[{"fix":"Ensure Python >=3.9 and upgrade the library.","message":"Version 6.0 drops support for Python 2 and Python <3.9. Upgrade your Python version if you are on older releases.","severity":"breaking","affected_versions":"<=5.x"},{"fix":"Use layer_name='default' instead of layer='default' if using ZCML.","message":"The 'layer' attribute in ZCML ptresource directive is deprecated in favor of 'layer_name' (string) or 'layer' as a dotted name. Using integer layer IDs is no longer supported.","severity":"deprecated","affected_versions":">=6.0"},{"fix":"Add <include package=\"zope.ptresource\" file=\"meta.zcml\" /> before using ptresource directive.","message":"Missing include of 'meta.zcml' will cause unknown directive error. The ptresource directive is not available until the meta.zcml is loaded.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add <include package=\"zope.ptresource\" file=\"meta.zcml\" /> in your configure ZCML.","cause":"The package's meta.zcml has not been included before using the ptresource directive.","error":"zope.configuration.config.ConfigurationError: ('Unknown directive', u'http://namespaces.zope.org/zope', u'ptresource')"},{"fix":"Replace layer=\"123\" with layer_name=\"some_name\" or a dotted path to a layer interface.","cause":"Using deprecated integer layer parameter in ZCML with newer version that expects layer_name.","error":"TypeError: __init__() got an unexpected keyword argument 'layer'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}