Plug in API Concordance Persistence - czcorpus/kontext GitHub Wiki

Plug-ins / [conc_persistence]

interface: plugins.abstract.conc_persistence.AbstractConcPersistence type: required

Original Bonito 2 and older KonText versions keep all the parameters specifying a concordance (i.e. original query, filters, samples etc.) in a URL of a page. Although it is in general a good idea (links can be copied and accessed by anyone, HTTP method types are not misused), the problem arises with the limited length of URL (starting circa from 2KB one cannot be sure that the application will work properly).

The conc_persistence plugin allows storing these parameters into a database and return a placeholder code which is then passed via URL (in a similar way how numerous URL shortening services work).

# AbstractConcPersistence.is_valid_id(data_id)

Returns True if data_id is a valid data identifier else False is returned

arguments:

  • data_id -- an identifier to be tested

# AbstractConcPersistence.open(data_id)

Loads operation data according to the passed data_id argument. The data are assumed to be public (as are URL parameters of a query).

arguments:

  • data_id -- an unique ID of operation data

returns:

  • a dictionary containing operation data or None if nothing is found

# AbstractConcPersistence.store(user_id, curr_data, prev_data=None)

Stores the current operation (defined in curr_data) into the database. If also prev_date argument is provided then a comparison is performed and based on the result, one of the following actions is performed:

  • a new record is created and a new ID is returned
  • nothing is done and the current ID is returned.

arguments:

  • user_id -- database ID of the current user
  • curr_data -- a dictionary containing operation data to be stored; currently at least 'q' entry must be present
  • prev_data -- optional dictionary with previous operation data; again, 'q' entry must be there

returns:

  • new operation ID if a new record is created or current ID if no new operation is defined
⚠️ **GitHub.com Fallback** ⚠️