fietsboek.views.browse module

Views for browsing all tracks.

class fietsboek.views.browse.FavouriteFilter(user, favourite)

Bases: Filter

A Filter that accepts only favoured or non-favoured tracks.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.Filter

Bases: object

A class representing a filter that the user can apply to the track list.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.FilterCollection(filters)

Bases: Filter

A class that applies multiple Filter.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

classmethod parse(request)

Parse the filters from the given request.

Raises:

HTTPBadRequest – If the filters are malformed.

Parameters:

request (Request) – The request.

Return type:

FilterCollection

Returns:

The parsed filter.

class fietsboek.views.browse.LambdaFilter(compiler, matcher)

Bases: Filter

A Filter that works by provided lambda functions.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.PersonFilter(names)

Bases: Filter

A Filter that looks for the given tagged people, based on their name.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.ResultOrder(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum representing the different ways in which the tracks can be sorted in the result.

DATE_ASC = 'date-asc'
DATE_DESC = 'date-desc'
DURATION_ASC = 'duration-asc'
DURATION_DESC = 'duration-desc'
LENGTH_ASC = 'length-asc'
LENGTH_DESC = 'length-desc'
class fietsboek.views.browse.SearchFilter(search_terms)

Bases: Filter

A Filter that looks for the given search terms.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.Stream

Bases: RawIOBase

A Stream represents an in-memory buffered FIFO.

This is useful for the zipfile module, as it needs a file-like object, but we do not want to create an actual temporary file.

readall()

Read until EOF, using multiple read() call.

Return type:

bytes

write(b)
Return type:

int

class fietsboek.views.browse.TagFilter(tags)

Bases: Filter

A Filter that looks for the given tags.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

class fietsboek.views.browse.UserTaggedFilter(user)

Bases: Filter

A Filter that looks for a specific user to be tagged.

apply(track)

Check if the given track matches the filter.

Parameters:

track (TrackWithMetadata) – The track to check.

Return type:

bool

Returns:

True if the track matches.

compile(query, track)

Compile the filter into the SQL query.

Returns the modified query.

This method is optional, as a pure-Python filtering can be done via apply().

Parameters:
  • query (Select) – The original query to be modified, selecting over all tracks.

  • track (type[Track]) – The track mapper.

Return type:

Select

Returns:

The modified query.

fietsboek.views.browse.apply_order(query, track, order)

Applies a ORDER BY clause to the query.

Raises:

ValueError – If the given order does not exist.

Parameters:
  • query (Select) – The query to adjust.

  • track (type[Track]) – The aliased track class.

  • order (ResultOrder) – The order, one of the values given above.

Return type:

Select

Returns:

The modified query with the ORDER BY clause applied.

fietsboek.views.browse.archive(request)

Packs multiple tracks into a single archive.

Parameters:

request (Request) – The Pyramid request.

Return type:

Response

Returns:

The HTTP response.

fietsboek.views.browse.browse(request)

Returns the page that lets a user browse all visible tracks.

Parameters:

request (Request) – The Pyramid request.

Return type:

Response

Returns:

The HTTP response.