Package: cone.tile
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.UsageRegister tilesA tile is registered similar to a pyramid view. Registration is done with the
thecone.tile.tiledecorator on classes.fromcone.tileimporttilefromcone.tileimportTile@tile(name='b_tile',path='package:browser/templates/b_tile.pt',permission='view',strict=False)classBTile(Tile):passThere also exists acone.tile.register_tilefunction. It should not be used
directly any more.tiledecorator attaches this function to venusian for
deferred tile registration.fromcone.tileimportregister_tileregister_tile(name='a_tile',path='package:browser/templates/a_tile.pt',permission='view')tiledecorator accepts the following arguments:nameIdentifier of the tile (for later lookup).pathEither relative path to the template or absolute path or path prefixed
by the absolute package name delimeted by ‘:’. Ifpathis usedattributeis ignored.attributeAttribute on the given _class to be used to render the tile. Defaults torender.interfaceInterface or class of the pyramid model the tile is registered for.class_Class to be used to render the tile. usallycone.tile.Tileor a
subclass of. Promises to implementcone.tile.ITile. When thetiledecorator is used, the decorated class is expected as tile implementation.permissionEnables security checking for this tile. Defaults toview. If set toNonesecurity checks are disabled.strictWether to raiseForbiddenor not if rendering is not permitted.
Defaults toTrue. If set toFalsethe 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 tilesTile rendering with therender_tilefunctionfromcone.tileimportrender_tilerendered=render_tile(model,request,name)Inside templates which are bound to the tile, more tiles can be rendered on
current model and request viatile<tal:sometilereplace="structure tile('tilename')"/>The TileA tile is similar to what’s known in the zope world as content provider.Before rendering of the tile is done, thepreparefunction is called which
can be used to load data or whatever.Further, theshowflag is considered (which might have been set in thepreparefunction) and rendering is skipped if it evaluates toFalse.More on renderingThere 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 awebob.exc.HTTPFoundinstance. This causes rendering
of remaining tiles to be skipped andrequest.environ['redirect']to be set.cone.tile.render_templateRender template. Passes tile renderer to template. Considers redirection.
Returns empty string if redirection found.cone.tile.render_template_to_responseRender template to response. Passes tile renderer to template. Considers
redirection. Returns HTTPFound instance if redirection found, otherwise
rendered response.cone.tile.render_to_responseRenders some result to the response considering redirection. Returns
HTTPFound instance if redirection found, otherwise rendered response.ContributorsRobert NiederreiterJens KleinAttila OlahChanges1.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 usecgimodule if replacement modulehtmlavailable.
[rnix, 2019-03-24]Convert doctests to unittests.
[rnix, 2019-03-21]tiledecorator usesvenusianto defer tile registration now.
[rnix, 2015-11-06]Acceptnameas keyword instead of positional argument inregister_tileandtiledecorator.
[rnix, 2015-11-06]registerTilehas been renamed toregister_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.6Usetracebackmodule instead ofzope.exceptionsto format
exceptions inrender_template.
[rnix, 2017-10-06]0.9.5Removelog_exceptionutility and use registeredIDebugLoggerincone.tile._api.render_templatefor exception logging.
[rnix, 2017-03-24]0.9.4Tile registrationnameis taken fromTilesubclass if not given
inregisterTilefunction andtiledecorator.
[rnix, 2017-02-17]nameis now optional inregisterTilefunction andtiledecorator.
[rnix, 2017-02-17]Defaultattributeis nowNoneinregisterTilefunction andtiledecorator to ensure consideringattributefromTilesubclass
if set.
[rnix, 2017-02-17]Tile.name,Tile.pathandTile.attributecan be set onTilesubclass directly without being overwritten at tile registration if not
given.
[rnix, 2017-02-17]0.9.3Errors caught inrender_tilemay contain umlaute. Properly decode error
string.
[rnix, 2017-02-13]0.9.2Using 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="structuretile('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.1Tiles can be overwritten.
[rnix, 2012-05-22]Usezope.interface.implementerinstead ofzope.interface.implements.
[rnix, 2012-05-18]0.9Fit for pyramid 1.1 + 1.2
[rnix, 2011-09-08]Documentation
[rnix, 2011-09-08]Make it work
[jensens, rnix, et. al]LicenseCopyright (c) 2009-2021, BlueDynamics Alliance, Austria
Copyright (c) 2021-2022, 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.