proso_common package

Submodules

proso_common.context_processors module

proso_common.context_processors.config_processor(request)[source]

proso_common.json_enrich module

proso_common.json_enrich.env_variables(request, json_list, nested, variable_type)[source]
proso_common.json_enrich.url(request, json_list, nested, url_name='show_{}', ignore_get=None)[source]

Enrich the given list of objects, so they have URL.

Parameters:
  • request (django.http.request.HttpRequest) – request which is currently processed
  • json_list (list) – list of dicts (JSON objects to be enriched)
  • url_name (str|fun) – pattern to create a url name taking object_type
  • ignore_get (list) – list of GET parameters which are ignored when the URL is generated
Returns:

list of dicts (enriched JSON objects)

Return type:

list

proso_common.middleware module

class proso_common.middleware.AuthAlreadyAssociatedMiddleware[source]

Bases: object

process_exception(request, exception)[source]
class proso_common.middleware.ErrorMiddleware[source]

Bases: object

process_exception(request, exception)[source]
class proso_common.middleware.GoogleAuthChangeDomain[source]

Bases: object

process_request(request)[source]
class proso_common.middleware.LanguageInDomainMiddleware[source]

Bases: object

process_request(request)[source]
process_response(request, response)[source]
class proso_common.middleware.LanguageInPathMiddleware[source]

Bases: object

process_request(request)[source]
class proso_common.middleware.ToolbarMiddleware[source]

Bases: object

process_response(request, response)[source]
proso_common.middleware.redirect_domain(request, target_domain)[source]
proso_common.middleware.set_lang(request, language_code)[source]

proso_common.models module

class proso_common.models.CommonMiddleware[source]

Bases: object

process_request(request)[source]
class proso_common.models.Config(id, app_name, key, content, content_hash)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Config.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Config.answer_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Config.customconfig_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Config.environmentinfo_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Config.objects = <proso_common.models.ConfigManager object>
Config.to_json(nested=False)[source]
class proso_common.models.ConfigManager[source]

Bases: django.db.models.manager.Manager

from_content(content, app_name=None, key=None)[source]
class proso_common.models.CustomConfig(id, config, user, condition_key, condition_value)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CustomConfig.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CustomConfig.config

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

CustomConfig.objects = <proso_common.models.CustomConfigManager object>
CustomConfig.user

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

class proso_common.models.CustomConfigManager[source]

Bases: django.db.models.manager.Manager

current_custom_configs(user_id)[source]
try_create(app_name, key, value, user_id, condition_key=None, condition_value=None)[source]
class proso_common.models.IntegrityCheck[source]

Bases: object

check()[source]

Perform integrity check

Returns:None if everything is OK, message (dict) otherwise
get_seed()[source]
set_seed(seed)[source]
proso_common.models.add_custom_config_filter(config_filter)[source]
proso_common.models.check_user_or_time_overridden(sender, instance, **kwargs)[source]
proso_common.models.current_custom_configs()[source]
proso_common.models.get_config(app_name, key, config_name=None, required=False, default=None)[source]
proso_common.models.get_content_hash(content)[source]
proso_common.models.get_custom_exports()[source]
proso_common.models.get_global_config(config_name=None)[source]
proso_common.models.get_integrity_checks()[source]
proso_common.models.get_tables_allowed_to_export()[source]
proso_common.models.instantiate_from_config(app_name, key, default_class=None, default_parameters=None, pass_parameters=None, config_name=None)[source]
proso_common.models.instantiate_from_config_list(app_name, key, pass_parameters=None, config_name=None)[source]
proso_common.models.reset_custom_config_filters()[source]
proso_common.models.reset_custom_configs()[source]
proso_common.models.reset_url_overridden()[source]

proso_common.urls module

proso_common.views module

proso_common.views.config(request)[source]
proso_common.views.csv(request, filename=None)[source]
proso_common.views.custom_config(request)[source]

Save user-specific configuration property.

POST parameters (JSON keys):
app_name: application name for which the configuration property is
valid (e.g., proso_common)

key: name of the property value: value of the property (number, string, boolean, ...) condition_key (optional): name of the condition which is used to filter the property condition_value (optional): value for the condition filtering the property

proso_common.views.languages(request)[source]

Returns languages that are available in the system.

Returns Dict: language_code -> domain

proso_common.views.log(request)[source]

Log an event from the client to the server.

POST parameters (JSON keys):
message:
description (str) of the logged event
level:
debug|info|warn|error
data:
additional data (JSON) describing the logged event
proso_common.views.show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None)[source]

Return list of objects of the given type.

GET parameters:
limit:
number of returned objects (default 10, maximum 100)
page:
current page number
filter_column:
column name used to filter the results
filter_value:
value for the specified column used to filter the results
user:
identifier of the current user
all:
return all objects available instead of paging; be aware this parameter can be used only for objects for wich the caching is turned on
db_orderby:
database column which the result should be ordered by
json_orderby:
field of the JSON object which the result should be ordered by, it is less effective than the ordering via db_orderby; be aware this parameter can be used only for objects for which the caching is turned on
desc
turn on the descending order
stats:
turn on the enrichment of the objects by some statistics
html
turn on the HTML version of the API
environment
turn on the enrichment of the related environment values
proso_common.views.show_one(request, post_process_fun, object_class, id, template='common_json.html')[source]

Return object of the given type with the specified identifier.

GET parameters:
user:
identifier of the current user
stats:
turn on the enrichment of the objects by some statistics
html
turn on the HTML version of the API

Module contents