Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install bda.bfg.tile

How to install bda.bfg.tile

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install bda.bfg.tile
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0 Available View build log
Windows (64-bit)
1.0 Available View build log
Mac OS X (10.5+)
1.0 Available View build log
Linux (32-bit)
1.0 Available View build log
Linux (64-bit)
1.0 Available View build log
Web
 
License
GNU General Public Licence
Dependencies
Imports
Lastest release
version 1.0 on Jan 5th, 2011

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, or omit even attribute kw argument, then the attribute render is called as default rendering 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>'

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.