This project has been archived by its maintainers, and is no longer receiving any updates.
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.
Imports.:
>>> from bda.bfg.tile import Tile >>> from bda.bfg.tile import TileRenderer >>> from bda.bfg.tile import registerTile >>> from bda.bfg.tile import tile
We need some dummies as model and request.:
>>> class Model(object): pass
>>> model = Model()
>>> from repoze.bfg.request import DEFAULT_REQUEST_FACTORIES
>>> request = DEFAULT_REQUEST_FACTORIES[None]['factory'](environ={})
The pure Tile itself. Normally you do not create this directly, this is done due registration, see below.:
>>> mytile = Tile('testdata/tile1.pt', None)
>>> mytile(model, request)
u'<span>Tile One</span>'
Register a tile using the prior template testtemplate. When no object is given, the default tile is instanciated as above.:
>>> registerTile('tileone', 'testdata/tile1.pt')
Render the already registered tile.:
>>> TileRenderer(model, request)('tileone')
u'<span>Tile One</span>'
Now the decorator - level=1 is needed for the doctest only to reduce the module level.:
>>> @tile('tiletwo', 'testdata/tile2.pt', level=1)
... class Tile2(Tile):
... data = u'custom'
>>> TileRenderer(model, request)('tiletwo')
u'<span>Tile Two: <b><span>Tile One</span></b></span>'
You can define an attribute which is responsible to render the tile instead of defining a template. By default render is taken. With the keyword argument attribute you can point to a different attribute.:
>>> @tile('attrtile') ... class Tile2(Tile): ... def render(self): ... return u'<h1>Rendered via attribute call</h1>' >>> TileRenderer(model, request)('attrtile') u'<h1>Rendered via attribute call</h1>'>>> @tile('attrtile', attribute='foobar') ... class Tile2(Tile): ... def foobar(self): ... return u'<h1>Rendered via attribute foobar call</h1>' >>> TileRenderer(model, request)('attrtile') u'<h1>Rendered via attribute foobar call</h1>'
Metadata
Release files for bda.bfg.tile 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bda.bfg.tile-1.0.tar.gz | 5.0 kB | Without provenance | Details for bda.bfg.tile-1.0.tar.gz |
Release files / bda.bfg.tile-1.0.tar.gz
| Download URL | bda.bfg.tile-1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18ab1b358b7a40bda8820f0f0ae0e8d8d1bdaa92a63ebffc5f8f1010470e3ed8
|
|
BLAKE2b-256 checksum How to use checksums |
a9905fbb2f0d93a294201f80ba127450e3406749c22623df001f4bbbbcf0e0b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bda.bfg.tile 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.