Skip to content

Plug in API User Items

Tomas Machalek edited this page Apr 25, 2016 · 2 revisions

Plug-ins / [user_items]

⚠️ the API is fresh and is likely to change

interface: plugins.abstract.user_items.AbstractUserItems type: required

This plug-in allows users to "bookmark" items (e.g. current corpus+subcorpus, aligned corpora etc.).

In general this can be omitted as some corparch plug-in implementations may provide sufficient functionality to select any corpus/subcorpus. The current implementation is not finished yet.

# AbstractUserItems.from_dict(data)

According to provided data it returns a proper implementation of plugins.abstract.user_items.GeneralItem.

arguments:

  • data -- a dict

# AbstractUserItems.to_json(obj)

Exports a GeneralItem instance or a list of GeneralItem instances (both variants must be supported) to JSON

# AbstractUserItems.get_user_items(user_id)

Returns a list of user items (GeneralItem implementations)

arguments:

  • user_id -- a database ID of a user

returns:

  • a list or a compatible structure containing GeneralItem objects

# AbstractUserItems.add_user_item(user_id, item)

Adds (persistently) an item to user's list.

arguments:

  • user_id -- a database ID of a user
  • item -- an instance of GeneralItem implementation

# AbstractUserItems.delete_user_item(user_id, item_id)

Removes (in a persistent way) an item from user's list.

arguments:

  • user_id -- a databse ID of a user
  • item_id -- an ID of GeneralItem instance

# AbstractUserItems.infer_item_key(corpname, usesubcorp, aligned_corpora)

Infers a user_item key (~ id) from provided parameters (e.g. if usesubcorp is empty and so is aligned_corpora we know for sure that the unknown item is 'corpus' and the respective key will consist only from corpname.

This is used to extract information about currently used (sub)corpus/aligned corpus.

arguments:

  • corpname -- a canonical corpus name
  • usesubcorp -- a subcorpus name
  • aligned_corpora -- a list of canonical corpora names

returns:

  • a string identifier of guessed object type
Clone this wiki locally