The Virtual Brain Project

Table Of Contents

Previous topic

web Package

Next topic

burst Package

This Page

controllers Package

base_controller

The Main class in this file is initialized in web/run.py to be served on the root of the Web site.

This is the main UI entry point.

class tvb.interfaces.web.controllers.base_controller.BaseController[source]

Bases: object

This class contains the methods served at the root of the Web site.

error(*a, **b)[source]

Error page to redirect when something extremely bad happened

fill_default_attributes(template_dictionary, escape_db_operations=False)[source]

Fill into ‘template_dictionary’ data that we want to have ready in UI.

fill_overlay_attributes(template_dictionary, title, description, content_template, css_class, tabs_horizontal=None, overlay_indexes=None, tabs_vertical=None)[source]

This method prepares parameters for rendering overlay (overlay.html)

Parameters:
  • title – overlay title
  • description – overlay description
  • content_template – path&name of the template file which will fill overlay content (without .html)
  • css_class – CSS class to be applied on overlay
  • tabs_horizontal – list of strings containing names of the tabs spread horizontally
  • tabs_vertical – list of strings containing names of the tabs spread vertically
static get_url_adapter(step_key, adapter_id, back_page=None)[source]

Compute the URLs for a given adapter. Same URL is used both for GET and POST.

index()[source]

/ Path response Redirects to /tvb

static mark_file_for_delete(file_name, delete_parent_folder=False)[source]

This method stores provided file name in session, and later on when request is done, all these files/folders are deleted

Parameters:
  • file_name – name of the file or folder to be deleted
  • delete_parent_folder – specify if the parent folder of the file should be removed too.
showBlockerOverlay(*a, **b)[source]

Returns the content of the blocking overlay (covers entire page and do not allow any action)

tvb(*a, **b)[source]

/tvb URL Returns the home page with the messages stored in the user’s session.

update_operations_count()[source]

If a project is selected, update Operation Numbers in call-out.

common

Constants and functions used by all controllers .. moduleauthor:: Mihai Andrei <mihai.andrei@codemart.ro>

exception tvb.interfaces.web.controllers.common.NotAllowed(message, redirect_url)[source]

Bases: tvb.basic.traits.exceptions.TVBException

Raised when accessing a resource is not allowed

exception tvb.interfaces.web.controllers.common.NotAuthenticated(message, redirect_url)[source]

Bases: tvb.interfaces.web.controllers.common.NotAllowed

Raised when accessing a protected method with no user logged in

tvb.interfaces.web.controllers.common.add2session(key, value)[source]

Set in session, at a key, a value

tvb.interfaces.web.controllers.common.expire_session()[source]

Expires and cleans current session.

tvb.interfaces.web.controllers.common.get_current_project()[source]

Get current Project from session

tvb.interfaces.web.controllers.common.get_from_session(attribute)[source]

check if something exists in session and return

tvb.interfaces.web.controllers.common.get_logged_user()[source]

Get current logged User from session

tvb.interfaces.web.controllers.common.get_message_from_session()[source]
tvb.interfaces.web.controllers.common.has_error_message()[source]

check if the session contains an error message

tvb.interfaces.web.controllers.common.pop_message_from_session()[source]

Pops the message stored in the session and it’s type If no message is present returns an empty info message :returns: a message dict

tvb.interfaces.web.controllers.common.remove_from_session(key)[source]

Remove from session an attributes if exists.

tvb.interfaces.web.controllers.common.set_error_message(msg)[source]

Set error message in session

tvb.interfaces.web.controllers.common.set_important_message(msg)[source]

Set info message in session

tvb.interfaces.web.controllers.common.set_info_message(msg)[source]

Set info message in session

tvb.interfaces.web.controllers.common.set_message(msg, m_type='INFO')[source]

Set in session a message of a given type

tvb.interfaces.web.controllers.common.set_warning_message(msg)[source]

Set warning message in session

decorators

Decorators for Cherrypy exposed methods are defined here.

tvb.interfaces.web.controllers.decorators.check_admin(func)[source]

Decorator to check if a user is administrator before accessing a controller method

tvb.interfaces.web.controllers.decorators.check_user(func)[source]

Decorator to check if a user is logged before accessing a controller method.

tvb.interfaces.web.controllers.decorators.context_selected(func)[source]

Decorator to check if a project is currently selected.

tvb.interfaces.web.controllers.decorators.expose_fragment(template_name)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=False) @using_template2(template) @check_user

tvb.interfaces.web.controllers.decorators.expose_json(func)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=False) @jsonify @check_user

tvb.interfaces.web.controllers.decorators.expose_numpy_array(func)[source]
tvb.interfaces.web.controllers.decorators.expose_page(func)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=True) @using_template2(‘base_template’) @check_user

tvb.interfaces.web.controllers.decorators.handle_error(redirect)[source]

If redirect is true(default) all errors will generate redirects. Generic errors will redirect to the error page. Authentication errors to login pages. If redirect is false redirect will be converted to errors http 500 All errors are logged Redirect false is used by ajax calls

tvb.interfaces.web.controllers.decorators.jsonify(func)[source]

Decorator to wrap all JSON calls, and log on server in case of an exception.

tvb.interfaces.web.controllers.decorators.ndarray_to_http_binary(func)[source]

Decorator to wrap calls that return numpy arrays. It serializes them as binary http response

tvb.interfaces.web.controllers.decorators.profile_func(func)[source]
tvb.interfaces.web.controllers.decorators.settings(func)[source]

Decorator to check if a the settings file exists before allowing access to some parts of TVB.

tvb.interfaces.web.controllers.decorators.using_template(template_name)[source]

Decorator that renders a template

flow_controller

Steps which a user needs to execute for achieving a given action are described here.

class tvb.interfaces.web.controllers.flow_controller.FlowController[source]

Bases: tvb.interfaces.web.controllers.base_controller.BaseController

This class takes care of executing steps in projects.

NEW_SELECTION_NAME = 'New selection'
static accepted__aggregation_functions()[source]

Returns the list of aggregation functions that may be applied on arrays.

create_row_of_specs(*a, **b)[source]
default(*a, **b)[source]

Render a specific adapter. ‘data’ are arguments for POST

execute_post(project_id, submit_url, step_key, algorithm, **data)[source]

Execute HTTP POST on a generic step.

fill_default_attributes(template_dictionary, title='-')[source]

Overwrite base controller to add required parameters for adapter templates.

get_adapter_template(project_id, algorithm_id, is_upload=False, back_page=None)[source]

Get the template for an adapter based on the algo group id.

get_available_selections(*a, **b)[source]
get_pse_filters(*a, **b)[source]
get_simple_adapter_interface(*a, **b)[source]

AJAX exposed method. Will return only the interface for a adapter, to be used when tabs are needed.

get_template_for_adapter(project_id, step_key, stored_adapter, submit_url, session_reset=True, is_burst=True)[source]

Get Input HTML Interface template or a given adapter

getadapterinterface(*a, **b)[source]

AJAX exposed method. Will return only a piece of a page, to be integrated as part in another page.

getfiltereddatatypes(*a, **b)[source]

Given the name from the input tree, the dataType required and a number of filters, return the available dataType that satisfy the conditions imposed.

gettemplatefordimensionselect(*a, **b)[source]

Returns the HTML which contains the selects components which allows the user to reduce the dimension of a multi-dimensional array.

We try to obtain the aggregation_functions from the entity, which is a list of lists. For each dimension should be a list with the supported aggregation functions. We create a DICT for each of those lists. The key will be the name of the function and the value will be its label.

entity_gid
the GID of the entity for which is displayed the component
select_name
the name of the parent select. The select in which is displayed the entity with the given GID
parameters_prefix
a string which will be used for computing the names of the component
required_dimension
the expected dimension for the resulted array
expected_shape and operations
used for applying conditions on the resulted array e.g.: If the resulted array is a 3D array and we want that the length of the second dimension to be smaller then 512 then the expected_shape and operations should be: expected_shape=x,512,x and operations='x,&lt;,x
prepare_group_launch(*a, **b)[source]

Receives as input a group gid and an algorithm given by category and id, along with data that gives the name of the required input parameter for the algorithm. Having these generate a range of GID’s for all the DataTypes in the group and launch a new operation group.

read_binary_datatype_attribute(*a, **b)[source]
read_datatype_attribute(*a, **b)[source]

Retrieve from a given DataType a property or a method result.

Returns:

JSON representation of the attribute.

Parameters:
  • entity_gid – GID for DataType entity
  • dataset_name – name of the dataType property /method
  • flatten – result should be flatten before return (use with WebGL data mainly e.g vertices/triangles) Ignored if the attribute is not an ndarray
  • datatype_kwargs – if passed, will contain a dictionary of type {‘name’ : ‘gid’}, and for each such pair, a load_entity will be performed and kwargs will be updated to contain the result
  • kwargs – extra parameters to be passed when dataset_name is method.
readserverstaticfile(*a, **b)[source]

Retrieve file from Local storage, having a File System Path.

reload_burst_operation(*a, **b)[source]

Find out from which burst was this operation launched. Set that burst as the selected one and redirect to the burst page.

reloadoperation(*a, **b)[source]

Redirect to Operation Input selection page, with input data already selected.

show_group_of_algorithms(*a, **b)[source]
step_analyzers(*a, **b)[source]

Choose exact action/adapter for current step.

step_connectivity(*a, **b)[source]

Display menu for Connectivity Footer tab.

stop_burst_operation(*a, **b)[source]

For a given operation id that is part of a burst just stop the given burst. :returns True when stopped operation was successfully.

stop_operation(*a, **b)[source]

Stop the operation given by operation_id. If is_group is true stop all the operations from that group.

store_exploration_section(*a, **b)[source]

Launching method for further simulations.

store_measure_points_selection(*a, **b)[source]

Save a MeasurePoints selection (new or update existing entity).

store_pse_filter(*a, **b)[source]

settings_controller

class tvb.interfaces.web.controllers.settings_controller.AsciiValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Allow only ascii strings

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 108
class tvb.interfaces.web.controllers.settings_controller.DiskSpaceValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for TVB disk space / user.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 103
class tvb.interfaces.web.controllers.settings_controller.MatlabValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for the number of vertices allowed for a surface

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 107
class tvb.interfaces.web.controllers.settings_controller.PortValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for OS Port number.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 104
class tvb.interfaces.web.controllers.settings_controller.SettingsController[source]

Bases: tvb.interfaces.web.controllers.users_controller.UserController

Controller for TVB-Settings web page. Inherit from UserController, to have the same fill_default_attributes method (with versionInfo).

check_db_url(*a, **b)[source]

Action on DB-URL validate button.

settings(*a, **b)[source]

Main settings page submit and get

validate_matlab_path(*a, **b)[source]

Check if the set path from the ui actually corresponds to a matlab executable.

class tvb.interfaces.web.controllers.settings_controller.SettingsForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Settings Page inputs.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 125
fields = {'MAXIMUM_NR_OF_OPS_IN_RANGE': <Int object 124 max=5000 min=5 not_empty=True>, 'URL_WEB': <URL object 115 not_empty=True require_tld=False>, 'ADMINISTRATOR_EMAIL': <Email object 113 not_empty=True>, 'MATLAB_EXECUTABLE': <MatlabValidator object 121>, 'MAXIMUM_NR_OF_THREADS': <ThreadNrValidator object 122>, 'WEB_SERVER_PORT': <PortValidator object 114>, 'USR_DISK_SPACE': <DiskSpaceValidator object 120 not_empty=True>, 'DEPLOY_CLUSTER': <Bool object 118>, 'TVB_STORAGE': <AsciiValidator object 119 not_empty=True>, 'URL_VALUE': <UnicodeString object 117 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'ADMINISTRATOR_PASSWORD': <UnicodeString object 112 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'SELECTED_DB': <UnicodeString object 116 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'MAXIMUM_NR_OF_VERTICES_ON_SURFACE': <SurfaceVerticesNrValidator object 123>, 'ADMINISTRATOR_NAME': <All [<UnicodeString object 109 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, <PlainText object 110 regex=<_sre.SRE_Pattern object at 0x7f71f2b40660>>]>}
pre_validators = []
class tvb.interfaces.web.controllers.settings_controller.SurfaceVerticesNrValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for the number of vertices allowed for a surface

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
MAX_VALUE = 16777217
declarative_count = 106
class tvb.interfaces.web.controllers.settings_controller.ThreadNrValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator number of threads.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 105

users_controller

Here, user related tasks are described. Basic authentication processes are described here, but also user related annotation (checked-logged).

class tvb.interfaces.web.controllers.users_controller.EditUserForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate fields on user-edit

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = [<FieldsMatch object 85 field_names=('password', 'password2')>, <RequireIfMissing object 86 present='old_password' required='password'>]
declarative_count = 87
fields = {'password2': <UnicodeString object 83 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'password': <UnicodeString object 82 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'old_password': <UnicodeString object 81 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'email': <Email object 84 if_missing=None>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.LoginForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate for Login UI Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 65
empty_msg = 'Please enter a value'
fields = {'username': <UnicodeString object 63 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8' use_builtins_gettext=False>, 'password': <UnicodeString object 64 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8' use_builtins_gettext=False>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.RecoveryForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Recover Password Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 80
fields = {'username': <ByteString object 79 not_empty=False>, 'email': <Email object 78 not_empty=True>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.RegisterForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Register Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = [<FieldsMatch object 76 field_names=('password', 'password2')>]
declarative_count = 77
fields = {'username': <All [<UnicodeString object 67 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, <PlainText object 68 regex=<_sre.SRE_Pattern object at 0x7f71f2b40660>>, <UniqueUsername object 69>]>, 'comment': <UnicodeString object 74 inputEncoding='utf-8' outputEncoding='utf-8'>, 'password2': <UnicodeString object 72 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'role': <UnicodeString object 75 inputEncoding='utf-8' outputEncoding='utf-8'>, 'password': <UnicodeString object 71 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'email': <Email object 73 not_empty=True>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.UniqueUsername(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator to check that a given user-name is unique.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 66
class tvb.interfaces.web.controllers.users_controller.UserController[source]

Bases: tvb.interfaces.web.controllers.base_controller.BaseController

This class takes care of the user authentication and/or register.

create_new(*a, **b)[source]

Create new user with data submitted from UI.

fill_default_attributes(template_dictionary)[source]

Fill into ‘template_dictionary’ data that we want to have ready in UI.

get_color_schemes_json(*a, **b)[source]
get_viewer_color_scheme(*a, **b)[source]
index(*a, **b)[source]

Login page (with or without messages).

is_storage_ready(*a, **b)[source]

Check if all storage updates are done

logout(*a, **b)[source]

Logging out user and clean session

profile(*a, **b)[source]

Display current user’s profile page. On POST: logout, or save password/email.

recoverpassword(*a, **b)[source]

This form should reset a password for a given userName/email and send a notification message to that email.

register(*a, **b)[source]

This register form send an e-mail to the user and to the site admin.

set_viewer_color_scheme(*a, **b)[source]
switch_online_help(*a, **b)[source]

Switch flag that displays online helps

usermanagement(*a, **b)[source]

Display a table used for user management.

validate(*a, **b)[source]

A link to this page will be sent to the administrator to validate the registration of each user.