Skip to main content

This package provides rendering snippets of markup organized as tiles for the pyramid framework.

A tile is a piece of web application, i.e. a form, a navigation, etc.

Splitting your application in such small and logic application parts makes it easy to re-use this application, simplifies application AJAXification and the use of same application parts in different manners.

Latest PyPI version Number of PyPI downloads Test cone.tile

Usage

Register tiles

A tile is registered similar to a pyramid view. Registration is done with the the cone.tile.tile decorator on classes.

from cone.tile import tile
from cone.tile import Tile

@tile(
    name='b_tile',
    path='package:browser/templates/b_tile.pt',
    permission='view',
    strict=False)
class BTile(Tile):
    pass

There also exists a cone.tile.register_tile function. It should not be used directly any more. tile decorator attaches this function to venusian for deferred tile registration.

from cone.tile import register_tile

register_tile(
    name='a_tile',
    path='package:browser/templates/a_tile.pt',
    permission='view')

tile decorator accepts the following arguments:

name

Identifier of the tile (for later lookup).

path

Either relative path to the template or absolute path or path prefixed by the absolute package name delimeted by ‘:’. If path is used attribute is ignored.

attribute

Attribute on the given _class to be used to render the tile. Defaults to render.

interface

Interface or class of the pyramid model the tile is registered for.

class_

Class to be used to render the tile. usally cone.tile.Tile or a subclass of. Promises to implement cone.tile.ITile. When the tile decorator is used, the decorated class is expected as tile implementation.

permission

Enables security checking for this tile. Defaults to view. If set to None security checks are disabled.

strict

Wether to raise Forbidden or not if rendering is not permitted. Defaults to True. If set to False the exception is consumed and an empty unicode string is returned.

Tiles can be overwritten later while application initialization by just registering it again. This is useful for application theming and customization.

Rendering tiles

Tile rendering with the render_tile function

from cone.tile import render_tile
rendered = render_tile(model, request, name)

Inside templates which are bound to the tile, more tiles can be rendered on current model and request via tile

<tal:sometile replace="structure tile('tilename')" />

The Tile

A tile is similar to what’s known in the zope world as content provider.

Before rendering of the tile is done, the prepare function is called which can be used to load data or whatever.

Further, the show flag is considered (which might have been set in the prepare function) and rendering is skipped if it evaluates to False.

More on rendering

There are helper functions for rendering which pass the tile renderer to templates for invoking child tiles and consider redirections.

The tile class provides a redirect function, which expects either a string containing a URL or a webob.exc.HTTPFound instance. This causes rendering of remaining tiles to be skipped and request.environ['redirect'] to be set.

cone.tile.render_template

Render template. Passes tile renderer to template. Considers redirection. Returns empty string if redirection found.

cone.tile.render_template_to_response

Render template to response. Passes tile renderer to template. Considers redirection. Returns HTTPFound instance if redirection found, otherwise rendered response.

cone.tile.render_to_response

Renders some result to the response considering redirection. Returns HTTPFound instance if redirection found, otherwise rendered response.

Contributors

  • Robert Niederreiter

  • Jens Klein

  • Attila Olah

Changes

2.1.0 (2026-10-31)

  • Check tile permissions with request.has_permission when rendering instead of looking up the authentication and authorization policies when registering. Tiles are protected with a Pyramid security policy now, and regardless of whether a policy was configured before the tile was registered. [rnix]

  • Sort the imports with ruff (one per line, from imports first, no sections) and format the code with ruff format (90 characters per line, single quotes). [rnix]

  • Add import sorting (I rules) and the formatter settings to the ruff configuration in pyproject.toml. [rnix]

2.0.1 (2026-10-24)

  • Render a copy of the registered tile on every call. One tile object is registered per name, and Tile.__call__ sets model and request on it: two threads rendering the same tile at once shared that object, and a template could read the model and request of the other request. register_tile now registers a wrapper that renders a shallow copy. [rnix]

  • Drop the Python 2 remnants: IS_PY2 in cone.tile._api and the urllib/cgi import fallbacks. [rnix]

  • Modernise the code ruff flags as outdated: u'' prefixes, class X(object), .format() over f-strings. Behaviour unchanged. super(Class, self) is kept, see cone.app. [rnix]

  • Add qa.ruff domain to Makefile and pin the ruff rule selection in pyproject.toml, make check runs ruff check. [rnix]

2.0.0 (2026-02-03)

  • Refactor package layout to use pyproject.toml and implicit namespace packages. [rnix]

  • Setup Makefile. [lenadax]

  • Run tests with pytest. [lenadax]

1.2 (2025-10-25)

  • Pin upper versions of dependencies. [rnix]

  • Setup Makefile. [lenadax]

  • Run tests with pytest. [lenadax]

1.1 (2022-12-05)

  • Release wheel. [rnix]

1.0 (2019-11-07)

  • Drop pyramid support < 1.5. [rnix, 2019-03-24]

  • Python 3 compatibility. [rnix, 2019-03-24]

  • Do not use cgi module if replacement module html available. [rnix, 2019-03-24]

  • Convert doctests to unittests. [rnix, 2019-03-21]

  • tile decorator uses venusian to defer tile registration now. [rnix, 2015-11-06]

  • Accept name as keyword instead of positional argument in register_tile and tile decorator. [rnix, 2015-11-06]

  • registerTile has been renamed to register_tile. [rnix, 2015-11-06]

  • Update to pyramid 1.5 [rnix, 2015-11-02]

  • Remove useless test case due to this change. https://github.com/Pylons/pyramid/commit/4b552e539a1725356b9982261b73fd88de7d59a1#diff-bcda6948340ab38542fe18fd2365ac70R144 [rnix, 2015-11-02]

0.9.6

  • Use traceback module instead of zope.exceptions to format exceptions in render_template. [rnix, 2017-10-06]

0.9.5

  • Remove log_exception utility and use registered IDebugLogger in cone.tile._api.render_template for exception logging. [rnix, 2017-03-24]

0.9.4

  • Tile registration name is taken from Tile subclass if not given in registerTile function and tile decorator. [rnix, 2017-02-17]

  • name is now optional in registerTile function and tile decorator. [rnix, 2017-02-17]

  • Default attribute is now None in registerTile function and tile decorator to ensure considering attribute from Tile subclass if set. [rnix, 2017-02-17]

  • Tile.name, Tile.path and Tile.attribute can be set on Tile subclass directly without being overwritten at tile registration if not given. [rnix, 2017-02-17]

0.9.3

  • Errors caught in render_tile may contain umlaute. Properly decode error string. [rnix, 2017-02-13]

0.9.2

  • Using and depending now on zope.exceptions to format tracebacks with supplements. [jensens, 2012-06-06]

  • Improved visibility of tracebacks, they appear now in the error log. even if an expression like `tal:replace="structure tile('editform')"` ate it, the traceback is logged. traceback supplements are rendered. [jensens, 2012-06-05]

  • Removed superfluos try except [jensens, 2012-06-05]

  • Fixed dependencies for integrated tests [jensens, 2012-06-05]

0.9.1

  • Tiles can be overwritten. [rnix, 2012-05-22]

  • Use zope.interface.implementer instead of zope.interface.implements. [rnix, 2012-05-18]

0.9

  • Fit for pyramid 1.1 + 1.2 [rnix, 2011-09-08]

  • Documentation [rnix, 2011-09-08]

  • Make it work [jensens, rnix, et. al]

License

Copyright (c) 2009-2021, BlueDynamics Alliance, Austria Copyright (c) 2021-2025, Cone Contributors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for cone.tile 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cone.tile 2.1.0
File Size Uploaded Provenance Actions
cone_tile-2.1.0.tar.gz 17.9 kB Without provenance Details for cone_tile-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cone.tile 2.1.0
File Interpreter ABI Platform Actions
cone_tile-2.1.0-py3-none-any.whl Python 3 none any Details for cone_tile-2.1.0-py3-none-any.whl

Total release size: 36.3 kB

Release files / cone_tile-2.1.0.tar.gz

Download URL cone_tile-2.1.0.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5f15b23b5b16c258d0cdf670821d80639f97837aadd00ff8f2ca315eb14d078a
BLAKE2b-256 checksum
How to use checksums
c4f2ac288361efd02dd8792e3f03b63ad35bbad6433d7463945bcdb4bcb1a503
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / cone_tile-2.1.0-py3-none-any.whl

Download URL cone_tile-2.1.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5a803c032cfdedd5cc671098fcfb33a038caee5a29a5855894b852b8626408b
BLAKE2b-256 checksum
How to use checksums
25ca32a25bb491826dc1f0c3bbb19a9181c98a2a385d1191080b15d32574aee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for cone.tile 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page