<commit_before>package org.scalatra

import scala.util.DynamicVariable

/**
 * The Scalatra DSL requires a dynamically scoped request and response.
 * This trick is explained in greater detail in <NAME>'s blog
 * post about Step, out of which Scalatra grew:
 *
 * http://www.riffraff.info/2009/4/11/step-a-scala-web-picoframework
 */
trait DynamicScope {
  type RequestT >: Null <: Request
  type ResponseT >: Null <: Response

  /**
   * The currently scoped request.  Valid only inside the `handle` method.
   */
  implicit def request: RequestT = dynamicRequest.value

  private[this] val dynamicRequest = new DynamicVariable[RequestT](null)

  /**
   * The currently scoped response.  Valid only inside the `handle` method.
   */
  implicit def response: ResponseT = dynamicResponse.value

  private[this] val dynamicResponse = new DynamicVariable[ResponseT](null)

  protected def withRequestResponse[A](request: RequestT, response: ResponseT)(f: => A) = {
    withRequest(request) {
      withResponse(response) {
	f
      }
    }
  }

  /**
   * Executes the block with the given request bound to the `request`
   * method.
   */
  protected def withRequest[A](request: RequestT)(f: => A) = 
    dynamicRequest.withValue(request) {
      f
    }

  /**
   * Executes the block with the given response bound to the `response`
   * method.
   */
  protected def withResponse[A](response: ResponseT)(f: => A) =
    dynamicResponse.withValue(response) {
      f
    }

  @deprecated("Do not invoke directly. Use `withRequest` to change the binding, or request to get the value") // since 2.1
  protected def _request = dynamicRequest

  @deprecated("Do not invoke directly. Use `withRequest` to change the binding, or `response` to get the value") // since 2.1
  protected def _response = dynamicResponse
}<commit_msg>Update deprecation message for _response<commit_after>package org.scalatra

import scala.util.DynamicVariable

/**
 * The Scalatra DSL requires a dynamically scoped request and response.
 * This trick is explained in greater detail in <NAME>'s blog
 * post about Step, out of which Scalatra grew:
 *
 * http://www.riffraff.info/2009/4/11/step-a-scala-web-picoframework
 */
trait DynamicScope {
  type RequestT >: Null <: Request
  type ResponseT >: Null <: Response

  /**
   * The currently scoped request.  Valid only inside the `handle` method.
   */
  implicit def request: RequestT = dynamicRequest.value

  private[this] val dynamicRequest = new DynamicVariable[RequestT](null)

  /**
   * The currently scoped response.  Valid only inside the `handle` method.
   */
  implicit def response: ResponseT = dynamicResponse.value

  private[this] val dynamicResponse = new DynamicVariable[ResponseT](null)

  protected def withRequestResponse[A](request: RequestT, response: ResponseT)(f: => A) = {
    withRequest(request) {
      withResponse(response) {
	f
      }
    }
  }

  /**
   * Executes the block with the given request bound to the `request`
   * method.
   */
  protected def withRequest[A](request: RequestT)(f: => A) = 
    dynamicRequest.withValue(request) {
      f
    }

  /**
   * Executes the block with the given response bound to the `response`
   * method.
   */
  protected def withResponse[A](response: ResponseT)(f: => A) =
    dynamicResponse.withValue(response) {
      f
    }

  @deprecated("Do not invoke directly. Use `withRequest` to change the binding, or request to get the value") // since 2.1
  protected def _request = dynamicRequest

  @deprecated("Do not invoke directly. Use `withResponse` to change the binding, or `response` to get the value") // since 2.1
  protected def _response = dynamicResponse
}
{'fraction_non_alphanumeric': 0.10245231607629428, 'fraction_numerical': 0.005994550408719346, 'mean_word_length': 3.5153751537515374, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7315089', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1045, 'n_words': 354}