From 9805351b581ffb12c52eff68cf789f0dc7ea00e2 Mon Sep 17 00:00:00 2001 From: Adam Avramov Date: Mon, 5 Aug 2013 12:36:57 +0300 Subject: [PATCH 1/2] Rename APIView.initial() to APIView.initialize() --- rest_framework/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index 37bba7f02..aa8f74119 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -224,7 +224,7 @@ class APIView(View): negotiator=self.get_content_negotiator(), parser_context=parser_context) - def initial(self, request, *args, **kwargs): + def initialize(self, request, *args, **kwargs): """ Runs anything that needs to occur prior to calling the method handler. """ @@ -312,7 +312,7 @@ class APIView(View): self.headers = self.default_response_headers # deprecate? try: - self.initial(request, *args, **kwargs) + self.initialize(request, *args, **kwargs) # Get the appropriate handler method if request.method.lower() in self.http_method_names: From 9739aad649656570ff503fe749fd2dcf62cb973d Mon Sep 17 00:00:00 2001 From: Adam Avramov Date: Mon, 5 Aug 2013 12:36:57 +0300 Subject: [PATCH 2/2] Deprecate APIView.initial() in favor of APIView.initialize(). --- rest_framework/views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index 37bba7f02..47829fdcb 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -224,7 +224,7 @@ class APIView(View): negotiator=self.get_content_negotiator(), parser_context=parser_context) - def initial(self, request, *args, **kwargs): + def initialize(self, request, *args, **kwargs): """ Runs anything that needs to occur prior to calling the method handler. """ @@ -239,6 +239,11 @@ class APIView(View): neg = self.perform_content_negotiation(request) request.accepted_renderer, request.accepted_media_type = neg + def initial(self, request, *args, **kwargs): + raise DeprecationWarning("Call to deprecated method APIView.initial()." + " Please use APIView.initialize() instead.") + return self.initialize(request, *args, **kwargs) + def finalize_response(self, request, response, *args, **kwargs): """ Returns the final response object. @@ -312,7 +317,7 @@ class APIView(View): self.headers = self.default_response_headers # deprecate? try: - self.initial(request, *args, **kwargs) + self.initialize(request, *args, **kwargs) # Get the appropriate handler method if request.method.lower() in self.http_method_names: