Web apps

Resources

TODO

DataTables

DataTables are implemented as python classes, providing configuration and server-side processing for jquery datatables.

class clld.web.datatables.base.DataTable(req, model, eid=None, **kw)[source]

DataTables are used to manage (sort, filter, display) lists of instances of one model class.

base_query(query)[source]

Custom DataTables can overwrite this method to add joins, or apply filters.

Returns:sqlalchemy.orm.query.Query instance.
col_defs()[source]

Must be implemented by derived classes.

Returns:list of instances of clld.web.datatables.base.Col.
toolbar()[source]
xhr_query()[source]
Returns:a mapping to be passed as query parameters to the server when requesting table data via xhr.
class clld.web.datatables.base.Col(dt, name, get_object=None, model_col=None, format=None, **kw)[source]

DataTables are basically a list of column specifications.

A column in a DataTable typically corresponds to a column of an sqlalchemy model. This column can either be supplied directly via a model_col keyword argument, or we try to look it up as attribute with name “name” on self.dt.model.

format(item)[source]

called when converting the matching result items of a datatable’s search query to json.

get_obj(item)[source]

derived columns with a model_col not on self.dt.model should override this method.

order()[source]

called when collecting the order by clauses of a datatable’s search query

search(qs)[source]

called when collecting the filter criteria of a datatable’s search query

Adapters

class clld.web.adapters.base.Index(obj)[source]

Base class for adapters implementing IIndex

class clld.web.adapters.base.Json(obj)[source]

JavaScript Object Notation

class clld.web.adapters.base.Renderable(obj)[source]

Virtual base class for adapters

Adapters can provide custom behaviour either by specifying a template to use for rendering, or by overwriting the render method.

>>> r = Renderable(None)
>>> assert r.label == 'Renderable'
class clld.web.adapters.base.Representation(obj)[source]

Base class for adapters implementing IRepresentation

class clld.web.adapters.base.SolrDoc(obj)[source]

Document for indexing with Solr encoded in JSON

Linked Data

TODO