fietsboek.views.tileproxy module

Tile proxying layer.

While this might slow down the initial load (as we now load everything through fietsboek), we can cache the OSM tiles per instance, and we can provide better access control for services like thunderforest.com.

Additionally, this protects the users’ IP, as only fietsboek can see it.

fietsboek.views.tileproxy.CONNECTION_CLOSE_TIMEOUT = datetime.timedelta(seconds=2)

Timeout after which keep-alive connections are killed.

Note that new requests reset the timeout.

fietsboek.views.tileproxy.MAX_CONCURRENT_CONNECTIONS = 2

Maximum TCP connections per tile host.

fietsboek.views.tileproxy.PUNISHMENT_THRESHOLD = 10

Block a provider after that many requests have timed out.

fietsboek.views.tileproxy.PUNISHMENT_TTL = datetime.timedelta(seconds=600)

Block-out period after too many requests of a server have timed out.

fietsboek.views.tileproxy.TIMEOUT = datetime.timedelta(seconds=1, microseconds=500000)

Timeout when requesting new tiles from a source server.

fietsboek.views.tileproxy.TTL = datetime.timedelta(days=7)

Time to live of cached tiles.

class fietsboek.views.tileproxy.TileRequester

Bases: object

Implementation of the tile requester using requests sessions.

The benefit of this over doing requests.get is that we can re-use connections, and we ensure that we comply with the use policy of the tile servers by not hammering them with too many connections.

load_tile(url, headers=None)

Implementation of ITileRequester.load_tile().

Return type:

Response

fietsboek.views.tileproxy.extract_tile_layers(config)

Extract all defined tile layers from the settings.

Parameters:

config (Config) – The fietsboek config.

Return type:

List[TileLayerConfig]

Returns:

A list of extracted tile sources.

fietsboek.views.tileproxy.sources_for(request)

Returns all eligible tile sources for the given request.

Parameters:

request (Request) – The Pyramid request.

Return type:

List[TileLayerConfig]

Returns:

A list of tile sources.

fietsboek.views.tileproxy.tile_proxy(request)

Requests the given tile from the proxy.

Parameters:

request (pyramid.request.Request) – The Pyramid request.

Returns:

The HTTP response.

Return type:

pyramid.response.Response