mobyleConfig

handle the part of mobyle configuration stored in the mongodb

mobyleConfig API reference

Created on Nov. 28, 2012

@author: Olivier Sallou @contact: olivier.sallou@irisa.fr @license: GPLv3

class mobyle.common.mobyleConfig.MobyleConfig(doc=None, gen_skel=True, collection=None, lang='en', fallback_lang='en', schema_2_restore=None)[source]

Config loads mobyle configuration from database. It contains configuration that can be updated by administrators

bind_form(request)

Binds a request dictionnary to the object

Parameters:request (list) – request.params.items() in the form [ (key1,value1), (key1,value2), (key2,value1), ...]
Returns:list of fields in error
classmethod get_current()[source]

Return current active configuration

Returns:active MobyleConfig
classmethod get_display_list_fields(klass)

Get the list of fields to display for a list

Returns:dict
classmethod get_renderer(klass, name)

Gets the renderer for an object attribute

render(fields=None)

Render in HTML form an object

param: fields List of fields to show type: list rparam: HTML form rtype: str

Render in HTML a search form an object

param: fields List of fields to show, limited to first level of document type: list rparam: HTML form rtype: str

static renderer(klass, attr_name, attr, parent='')

Gets a renderer for an attribute

Parameters:
  • attr_name (str) – name of the attribute
  • attr (object) – attribute of the object
Returns:

selected renderer

classmethod search_by(klass, field)

In REST requests, search element by field instead of _id. Field must be a unique identifier. For the moment, this method

works only on primary attributes, not sub attributes of the object.

..TODO: manage sub attributes

Parameters:field (str) – Field name to use as key in search
classmethod set_display_fields(klass, fields)

Sets the fields to be displayed, and in which order

param: fields List of fields to show type: list

classmethod set_display_list_fields(klass, fields)

Sets the fields to be displayed for lists, and in which order Defaults to all fields (first level only) param: fields List of fields to show type: list

classmethod set_renderer(klass, name, renderer)

Sets the renderer for an object attribute

to_json()[source]

” Return JSON representation of the object

Returns:JSON representation of the config
Return type:str