Ensure that we are grabbing the correct scope.
340559
def _ensure_scope(level, global_dict=None, local_dict=None, resolvers=(),
                  target=None, **kwargs):
    """"""
    return Scope(level + 1, global_dict=global_dict, local_dict=local_dict,
                 resolvers=resolvers, target=target)
417674
def _get_scope_with_symbol(self, name):
        """"""
        scope = self
        while True:
            parent = scope.get_enclosing_scope()
            if parent is None:
                return

            if name in parent.symbols:
                return parent

            scope = parent
190539
public void setScope(String scope) {
        if (scope.equalsIgnoreCase("page")) {
            this.scope = PageContext.PAGE_SCOPE;
        } else if (scope.equalsIgnoreCase("request")) {
            this.scope = PageContext.REQUEST_SCOPE;
        } else if (scope.equalsIgnoreCase("session")) {
            this.scope = PageContext.SESSION_SCOPE;
        } else if (scope.equalsIgnoreCase("application")) {
            this.scope = PageContext.APPLICATION_SCOPE;
        }
        // TODO: Add error handling?  Needs direction from spec.
    }
1043829
def stack(new_scope = nil)
      old_stack_used = @this_stack_used
      if new_scope
        push(new_scope)
        @this_stack_used = true
      else
        @this_stack_used = false
      end

      yield
    ensure
      pop if @this_stack_used
      @this_stack_used = old_stack_used
    end
1244298
function shouldDeoptBasedOnScope(binding, refPath) {
  if (binding.scope.path.isProgram() && refPath.scope !== binding.scope) {
    return true;
  }
  return false;
}
995459
def run_deferred(self, deferred):
        """"""
        for handler, scope, offset in deferred:
            self.scope_stack = scope
            self.offset = offset
            handler()
566479
def check_scope(scope = nil)
      # If no scope is requested or the change has no scope include this change unchanged
      return self unless scope
      change_scope = /^\s*\[\w+\]/.match(@note)
      return self unless change_scope

      # change_scope is a string of format `[scope]`, need to strip the `[]` to compare the scope
      if change_scope[0][1..-2] == scope
        #  Change has the scope that is requested, strip the whole scope scope from the change note
        @note = change_scope.post_match.strip
        return self
      else
        #  Change has a different scope than requested
        return nil
      end
    end
208870
def session_scope(session_cls=None):
    """"""
    session = session_cls() if session_cls else Session()
    try:
        yield session
        session.commit()
    except Exception:
        session.rollback()
        raise
    finally:
        session.close()
520909
function setScope (scope) {
    // throw error if attempting operation on complete audit record
    assert.ok(!this.complete, 'cannot setScope on complete audit record')
    // set scope value
    this.scope = scope
    // allow request is complete
    this.complete = true
    // debug
    debug(this)
    // return set value
    return this.scope
}
562489
def _get_scopes(self):
        
        if self._read_only:
            scopes = (READ_ONLY_SCOPE,)
        else:
            scopes = (DATA_SCOPE,)

        if self._admin:
            scopes += (ADMIN_SCOPE,)

        return scopes
451262
def _call_scope(self, scope, *args, **kwargs):
        
        result = getattr(self._model, scope)(self, *args, **kwargs)

        return result or self
1104182
def has_visible_scopes?(resource)
      resource.participatory_space.scopes_enabled? &&
        resource.scope.present? &&
        resource.participatory_space.scope != resource.scope
    end
190297
def check_scope(self, token, request):
        http_method = request.method
        if not hasattr(self, http_method):
            raise OAuthError("HTTP method is not recognized")
        required_scopes = getattr(self, http_method)
        # a None scope means always allowed
        if required_scopes is None:
            return True
        
        # for non iterable types
        if isinstance(required_scopes, six.string_types):
            if token.allow_scopes(required_scopes.split()):
                return [required_scopes]
            return []
        allowed_scopes = []
        try:
            for scope in required_scopes:
                if token.allow_scopes(scope.split()):
                    allowed_scopes.append(scope)
        except:
            raise Exception('Invalid required scope values')
        else:
            return allowed_scopes
453160
def configure_scope(self, callback=None):  # noqa
        """"""

        client, scope = self._stack[-1]
        if callback is not None:
            if client is not None:
                callback(scope)

            return None

        @contextmanager
        def inner():
            if client is not None:
                yield scope
            else:
                yield Scope()

        return inner()
1274879
def lookup_in_scope(name, scope)
      n = scope.size
      while n >= 0
        tn = (scope[0,n] + [name]).join(':')
        task = @tasks[tn]
        return task if task
        n -= 1
      end
      nil
    end
262318
function() {
		var lastScope;

		// find the first reference scope
		var templateContext = this.getScope(function(scope) {
			lastScope = scope;
			return scope._context instanceof TemplateContext;
		});

		// if there is no reference scope, add one as the root
		if(!templateContext) {
			templateContext = new Scope(new TemplateContext());

			// add templateContext to root of the scope chain so it
			// can be found using `getScope` next time it is looked up
			lastScope._parent = templateContext;
		}
		return templateContext;
	}
1102873
def has_scope(self, scope):
        """"""
        if not self.is_oauth_session():
            return False
        if '*' in self._authentication:
            return True
        if isinstance(scope, six.string_types):
            scope = [scope]
        return all(s in self._authentication for s in scope)