Save given data in the current context and jump change current context to its parent
767943
function leaveContext(moreData) {
                        
                        // Some data is not needed on subchildren
                        if (depth === 1) {
                            currentContext.data.time = Date.now() - currentContext.data.timestamp - responseEndTime;
                        }

                        // Some data is not needed on subchildren
                        if (depth > 1) {
                            if (moreData && moreData.backtrace) {
                                delete moreData.backtrace;
                            }
                            if (moreData && moreData.resultsNumber) {
                                delete moreData.resultsNumber;
                            }
                        }

                        // Merge previous data with moreData (ovewrites if exists)
                        if (moreData) {
                            for (var key in moreData) {
                                currentContext.data[key] = moreData[key];
                            }
                        }

                        var parent = currentContext.parent;
                        if (parent === null) {
                            console.error('Error: trying to close root context in ContextTree');
                        } else {
                            currentContext = parent;
                        }

                        depth --;
                    }
936547
def data_changed(self, context):
        
        model = self._model
        self._image.set_data(model.data)
        self._image.set_extent((0, model.width, model.height, 0))
503897
function(e) {
            e.preventDefault();
            e.stopImmediatePropagation();
            $(this).trigger($.Event("contextmenu", { data: e.data, pageX: e.pageX, pageY: e.pageY }));
        }
550083
function() {
        var editDataSource = this.getProperty( 'editDataSource' );
        var destinationDataSource = this.getProperty( 'destinationDataSource' );
        var destinationProperty = this.getProperty( 'destinationProperty' );

        if( this._isObjectDataSource( editDataSource ) ) {
            var editedItem = editDataSource.getSelectedItem();
            var originItem = destinationDataSource.getProperty( destinationProperty );

            if( this._isRootElementPath( destinationProperty ) ) {
                this._overrideOriginItem( originItem, editedItem );
                destinationDataSource._includeItemToModifiedSet( originItem );
                destinationDataSource.saveItem( originItem, function() {
                    destinationDataSource.updateItems();
                } );
            } else {
                destinationDataSource.setProperty( destinationProperty, editedItem );
            }

        } else {
            destinationDataSource.updateItems();
        }
    }
1138443
function addToJSONRecursively(contextNames, data, obj) {
        var currentContexName = contextNames.shift();

        // last name
        if (!contextNames.length) {
            obj[currentContexName] = data;
            return;
        }

        if (!obj[currentContexName]) {
            obj[currentContexName] = {};
        }

        addToJSONRecursively(contextNames, data, obj[currentContexName]);
    }
315461
function childContext(path, context) {
  const { settings, parserOptions, parserPath } = context
  return {
    settings,
    parserOptions,
    parserPath,
    path,
  }
}
84945
def update(self, other_context):
        
        # convert a context instance into a dictionary
        if isinstance(other_context, orb.Context):
            other_context = copy.copy(other_context.raw_values)

        ignore = ('where', 'columns', 'scope')
        inherit_kwds = {}
        inherit_scope = {}
        inherit_columns = []
        inherit_where = orb.Query()

        # update from the base context
        base_context = other_context.pop('context', None)
        if base_context is not None:
            inherit_kwds = base_context.raw_values

        # use the default contexts
        else:
            for default in self.defaultContexts():
                if default is not None:
                    # extract expandable information
                    for k, v in default.raw_values.items():
                        if k not in ignore:
                            inherit_kwds[k] = copy.copy(v)

                    # merge where queries
                    where = default.where
                    if where is not None:
                        inherit_where &= where

                    # merge column queries
                    columns = default.columns
                    if columns is not None:
                        inherit_columns += list(columns)

                    # merge scope
                    scope = default.scope
                    if scope:
                        inherit_scope.update(scope)

        # update the inherited kwds
        for k, v in inherit_kwds.items():
            other_context.setdefault(k, v)

        # update the inherited query
        if inherit_where:
            other_context.setdefault('where', orb.Query())
            other_context['where'] &= inherit_where

        # update the inherited columns
        if inherit_columns:
            other_context['columns'] = inherit_columns + (other_context.get('columns') or [])

        # update the inherited scope
        if inherit_scope:
            new_scope = {}
            new_scope.update(inherit_scope)
            new_scope.update(other_context.get('scope') or {})
            other_context['scope'] = new_scope

        # convert the columns to a list
        if 'columns' in other_context and isinstance(other_context['columns'], (str, unicode)):
            other_context['columns'] = other_context['columns'].split(',')

        # convert where to query
        where = other_context.get('where')
        if isinstance(where, dict):
            other_context['where'] = orb.Query.fromJSON(where)

        if isinstance(where, (orb.Query, orb.QueryCompound)):
            other_context['where'] &= self.where

        # validate values
        if other_context.get('start') is not None and (type(other_context['start']) != int or other_context['start'] < 0):
            msg = 'Start needs to be a positive number, got {0} instead'
            raise orb.errors.ContextError(msg.format(other_context.get('start)')))
        if other_context.get('page') is not None and (type(other_context['page']) != int or other_context['page'] < 1):
            msg = 'Page needs to be a number equal to or greater than 1, got {0} instead'
            raise orb.errors.ContextError(msg.format(other_context.get('page')))
        if other_context.get('limit') is not None and (type(other_context['limit']) != int or other_context['limit'] < 1):
            msg = 'Limit needs to be a number equal to or greater than 1, got {0} instead'
            raise orb.errors.ContextError(msg.format(other_context.get('limit')))
        if other_context.get('pageSize') is not None and (type(other_context['pageSize']) != int or other_context['pageSize'] < 1):
            msg = 'Page size needs to be a number equal to or greater than 1, got {0} instead'
            raise orb.errors.ContextError(msg.format(other_context.get('pageSize')))

        # update the raw values
        self.raw_values.update({k: v for k, v in other_context.items() if k in self.Defaults})
445270
def merge_context(self, src=None):
        """"""
        if src is None:
            # This condition will be true only if the server doesn't return a
            # txn context after a query or mutation.
            return

        if self._ctx.start_ts == 0:
            self._ctx.start_ts = src.start_ts
        elif self._ctx.start_ts != src.start_ts:
            # This condition should never be true.
            raise Exception('StartTs mismatch')

        self._ctx.keys.extend(src.keys)
        self._ctx.preds.extend(src.preds)
685089
function Context(data, parent, path, env) {
	/** 
	 * Context will inherit of AsyncCollector to manage all internal or external asynchroneous calls.
	 * It allows us to know when a context and its descendants are stabilised(i.e.all data are up to date).
	 **/
	AsyncCollector.call(this);
	this.__yContext__ = true;
	this.data = (data !== undefined) ? data : {};
	this.map = {};
	this.binds = [];
	if (parent) {
		this.parent = parent;
		this.env = env ? new Context(env) : parent.env;
		if (path) {
			var self = this;
			this.path = path;
			this.data = this.data || parent.get(path);
			this.parent.subscribe(path, function(value, type, p, key) {
				// console.log('binded context update : ', type, path, p, key, value);
				if (!p.length)
					p.push('$this');
				switch (type) {
					case 'set':
						self.set(p, value, true);
						break;
					case 'push':
						self.push(p, value, true);
						break;
					case 'delete':
						self.del(p, true);
						break;
					case 'displaceItem':
						self.displaceItem(p, value, true);
						break;
					case 'insertItem':
						self.insertItem(p, value, true);
						break;
					case 'deleteItem':
						self.deleteItem(p, value, true);
						break;
				}
			}, true, this.binds);
		}
	} else
		this.env = env ? (env.__yContext__ ? env : new Env(env)) : Context.env;
}
401221
function (data) {
    this.on("change:parent", this._onParent);

    // copy the data to this object. Note this shaves a TON
    // of time off initializing any view, especially list items if we
    // use this method over @setProperties data
    if (false) {
      for(var key in data) {
        this[key] = data[key];
      }
    }

    // necessary to properly dispose this view so it can be recycled
    if (this.parent) this._onParent(this.parent);
  }
1340226
function(obj, objDict) {
	    var parent = objDict[ obj.parentPath ];
	    if (parent) {
		if (parent.Substates == undefined)
		    parent.Substates = [];
		parent.Substates.push( obj );
	    }
	}
1078433
function(e) {
            e.stopPropagation();
            var opt = $(this).data('contextMenu') || {};

            // obtain currently selected menu
            if (opt.$selected) {
                var $s = opt.$selected;
                opt = opt.$selected.parent().data('contextMenu') || {};
                opt.$selected = $s;
            }
            
            var $children = opt.$menu.children(),
                $prev = !opt.$selected || !opt.$selected.prev().length ? $children.last() : opt.$selected.prev(),
                $round = $prev;
            
            // skip disabled
            while ($prev.hasClass('disabled') || $prev.hasClass('not-selectable')) {
                if ($prev.prev().length) {
                    $prev = $prev.prev();
                } else {
                    $prev = $children.last();
                }
                if ($prev.is($round)) {
                    // break endless loop
                    return;
                }
            }
            
            // leave current
            if (opt.$selected) {
                handle.itemMouseleave.call(opt.$selected.get(0), e);
            }
            
            // activate next
            handle.itemMouseenter.call($prev.get(0), e);
            
            // focus input
            var $input = $prev.find('input, textarea, select');
            if ($input.length) {
                $input.focus();
            }
        }
454732
def set_context(context):
    """"""
    try:
        handler = logging.getLogger().handlers[0]
    except IndexError:
        # logging is not initialized
        return
    if not isinstance(handler, StructuredHandler):
        return
    handler.acquire()
    try:
        handler.local.context = context
    finally:
        handler.release()
104073
def put_value(self, value, timeout=None):
        """"""
        self._context.put(self._data.path + ["value"], value, timeout=timeout)
350601
function(context, node, args) {
		var data = args[0],
			parent = args[1] || context,
			path = args[2];
		node.context = new Context(data, parent, path);
	}
1192774
def _recursive_upsert(context, params, data):
    """"""
    children = params.get("children", {})
    nested_calls = []
    for child_params in children:
        key = child_params.get("key")
        child_data_list = ensure_list(data.pop(key))
        if isinstance(child_data_list, dict):
            child_data_list = [child_data_list]
        if not (isinstance(child_data_list, list) and
                all(isinstance(i, dict) for i in child_data_list)):
            context.log.warn(
                "Expecting a dict or a lost of dicts as children for key", key
            )
            continue
        if child_data_list:
            table_suffix = child_params.get("table_suffix", key)
            child_params["table"] = params.get("table") + "_" + table_suffix
            # copy some properties over from parent to child
            inherit = child_params.get("inherit", {})
            for child_data in child_data_list:
                for dest, src in inherit.items():
                    child_data[dest] = data.get(src)
                nested_calls.append((child_params, child_data))
    # Insert or update data
    _upsert(context, params, data)
    for child_params, child_data in nested_calls:
        _recursive_upsert(context, child_params, child_data)
803266
def save(self, reload=False):
        """"""
        self.wrapper.raw.save()
        if reload:
            self.reload()