From fb715e0c933b696cea9a277741b779da8377f580 Mon Sep 17 00:00:00 2001 From: Rodrigo Moraes Date: Sun, 17 Jul 2011 07:57:53 -0300 Subject: [PATCH] The WSGI App is now thread-safe by default. Deprecated webapp2_extras.local_app. Updated docs and version number. --- AUTHORS | 29 +++++-- CHANGES | 19 +++-- LICENSE | 128 ++++++++++++++++++++++++++++ docs/api/extras.local_app.rst | 4 + docs/conf.py | 4 +- docs/features.rst | 2 +- docs/guide/app.rst | 17 ++-- docs/guide/extras.rst | 2 +- docs/guide/request.rst | 6 +- docs/index.rst | 1 - docs/tutorials/quickstart.nogae.rst | 9 +- setup.py | 2 +- tests/extras_i18n_test.py | 2 +- tests/handler_test.py | 17 ++-- tests/misc_test.py | 2 + tests/test_base.py | 9 +- webapp2.py | 56 +++++++----- webapp2_extras/local_app.py | 47 +++------- 18 files changed, 243 insertions(+), 113 deletions(-) diff --git a/AUTHORS b/AUTHORS index 91d990e..9cb75dd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,10 +1,23 @@ webapp2 is maintained by Rodrigo Moraes . -Based on `webapp`_ with some functions and ideas borrowed from `WebOb`_, -`Tornado`_, `Werkzeug`_ and `Flask`_. - -.. _webapp: http://code.google.com/appengine/docs/python/tools/webapp/ -.. _WebOb: http://pythonpaste.org/webob/ -.. _Tornado: http://www.tornadoweb.org/ -.. _Werkzeug: http://werkzeug.pocoo.org/ -.. _Flask: http://flask.pocoo.org/ +webapp2 includes code or ideas ported or adapted from the following projects: + +- `Google App Engine SDK `_: + - Copyright (c) 2008 Google Inc. + - Apache 2.0 License. + +- `WebOb `_: + - Copyright (c) 2007 Ian Bicking and Contributors. + - MIT License. + +- `Werkzeug `_: + - Copyright (c) 2011 Werkzeug Team. + - BSD License. + +- `Tornado `_: + - Copyright (c) 2009 Facebook. + - Apache 2.0 License. + +- `Flask `_: + - Copyright (c) 2010 Armin Ronacher and Contributors. + - BSD License. diff --git a/CHANGES b/CHANGES index 7772be6..40b2729 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,13 @@ -Development version -=================== +Version 2.0 - July 17, 2011 +=========================== - Added support for the (not yet released) App Engine Python 2.7 SDK. +- Deprecated webapp2_extras.local_app. WSGIApplication is now thread-safe + by default when webapp2_extras.local is available. + webapp2_extras.local_app.WSGIApplication can still be imported, but it is + just an alias to webapp2.WSGIApplication (and a deprecation warning is + emitted when it is imported). + - Like DomainRoute, PathPrefixRoute now only tests the nested routes if the prefix matches. So now it is not only convenient but matches smartly and faster. ;) @@ -22,9 +28,10 @@ Development version - webapp2.urlunsplit() was removed from the public API. - Variables names in routes must now look like python identifiers - - this means that they can no longer start with a number. + this means that they can no longer start with a number, like before. -- Removed support for _anchor in uri_for() -- documented keyword is _fragment. +- Removed support for _anchor in uri_for() -- the documented keyword is + _fragment. - Removed support for handler functions receiving (request, response). The correct arguments for function handlers are (request, *args, **kwargs). @@ -32,8 +39,8 @@ Development version - webapp2_extras.json: - Fixed an issue with importing json on non-GAE environments (missing absolute import). - - Now imports simplejson directly instead of using Django, as it was - included since SDK 1.4.2. + - Now imports simplejson directly instead of using the one from Django, + since it is now included in the App Engine SDK (since version 1.4.2). - Added WSGIApplication.clear_globals(). Instead of app.set_globals(app=None, request=None), use app.clear_globals(). diff --git a/LICENSE b/LICENSE index 572c69c..b1e47ba 100644 --- a/LICENSE +++ b/LICENSE @@ -14,3 +14,131 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + +GOOGLE APP ENGINE SDK +===================== +Copyright 2008 Google Inc. +All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +WebOb +===== +Copyright (c) 2007 Ian Bicking and Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +Werkzeug +======== +Copyright (c) 2011 by the Werkzeug Team, see AUTHORS for more details. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Tornado +======= +Copyright 2009 Facebook + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. + + +Flask +===== +Copyright (c) 2010 by Armin Ronacher and contributors. See AUTHORS +for more details. + +Some rights reserved. + +Redistribution and use in source and binary forms of the software as well +as documentation, with or without modification, are permitted provided +that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + +* The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/docs/api/extras.local_app.rst b/docs/api/extras.local_app.rst index b9dfda1..8f30c65 100644 --- a/docs/api/extras.local_app.rst +++ b/docs/api/extras.local_app.rst @@ -4,5 +4,9 @@ Local App ========= .. module:: webapp2_extras.local_app +.. note:: + This module is deprecated. :class:`webapp2.WSGIApplication` is now + thread-safe by default when :mod:`webapp2_extras.local` is available. + .. autoclass:: WSGIApplication :members: set_globals diff --git a/docs/conf.py b/docs/conf.py index c9a66fe..db23640 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -63,9 +63,9 @@ # built documents. # # The short X.Y version. -version = '1.8.1' +version = '2.0' # The full version, including alpha/beta/rc tags. -release = '1.8.1' +release = '2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/features.rst b/docs/features.rst index a9f61f0..ddc3599 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -280,4 +280,4 @@ package provides common utilities that integrate well with webapp2: - Extra route classes -- to match subdomains and other conveniences - Support for third party libraries: Jinja2, Mako and Google's ProtoRPC - Support for threaded environments, so that you can use webapp2 outside of - App Engine + App Engine or in the upcoming App Engine Python 2.7 runtime diff --git a/docs/guide/app.rst b/docs/guide/app.rst index 7138bfd..c5b9391 100644 --- a/docs/guide/app.rst +++ b/docs/guide/app.rst @@ -200,11 +200,13 @@ or in production checking the 'SERVER_SOFTWARE' environ variable:: Thread-safe application ----------------------- -:class:`webapp2_extras.local_app.WSGIApplication` is a special class to be used -in threaded environments, e.g., outside App Engine. It uses thread-locals to -store request and app references, instead of simple class attributes which are -fine for App Engine. See in the :ref:`tutorials.quickstart.nogae` tutorial a -complete explanation about how to use it. +By default, webapp2 is thread-safe when the module +:class:`webapp2_extras.local` is available. This means that it can be used +outside of App Engine or in the upcoming App Engine Python 2.7 runtime. +This also works in non-threaded environments such as App Engine Python 2.5. + +See in the :ref:`tutorials.quickstart.nogae` tutorial an explanation on how +to use webapp2 outside of App Engine. Running the app @@ -261,8 +263,3 @@ access the app registry or configuration values:: app = webapp2.get_app() config_value = app.config.get('my-config-key') - -The application instance is stored as a class attribute, which is fine on App -Engine because there are no concurrent requests for the same Python interpreter -instance. For threaded environments, an application that supports threads must -be used as described in the :ref:`tutorials.quickstart.nogae` tutorial. diff --git a/docs/guide/extras.rst b/docs/guide/extras.rst index 464038c..2b3724f 100644 --- a/docs/guide/extras.rst +++ b/docs/guide/extras.rst @@ -8,7 +8,7 @@ webapp2. It includes: - Extra route classes -- to match subdomains and other conveniences - Support for third party libraries: Jinja2, Mako and Google's ProtoRPC - Support for threaded environments, so that you can use webapp2 outside of - App Engine + App Engine or in the upcoming App Engine Python 2.7 runtime Some of these modules (:ref:`api.extras.i18n`, :ref:`api.extras.jinja2`, :ref:`api.extras.mako` and :ref:`api.extras.sessions`) use configuration diff --git a/docs/guide/request.rst b/docs/guide/request.rst index 245bb14..0831da8 100644 --- a/docs/guide/request.rst +++ b/docs/guide/request.rst @@ -194,11 +194,7 @@ request. You can access it in ``request.app``. Getting the current request --------------------------- The active ``Request`` instance can be accessed during a request using the -function :func:`webapp2.get_request`. It is stored as a class attribute, -which is fine on App Engine because there are no concurrent requests for -the same Python interpreter instance. For threaded environments, -an application that supports threads must be used as described in the -:ref:`tutorials.quickstart.nogae` tutorial. +function :func:`webapp2.get_request`. Learn more about WebOb diff --git a/docs/index.rst b/docs/index.rst index 128a532..a1f4ca8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -77,7 +77,6 @@ API Reference - webapp2_extras api/extras.jinja2.rst api/extras.json.rst api/extras.local.rst - api/extras.local_app.rst api/extras.mako.rst api/extras.protorpc.rst api/extras.routes.rst diff --git a/docs/tutorials/quickstart.nogae.rst b/docs/tutorials/quickstart.nogae.rst index 45689b0..ac3854c 100644 --- a/docs/tutorials/quickstart.nogae.rst +++ b/docs/tutorials/quickstart.nogae.rst @@ -7,8 +7,7 @@ framework, as it offers these features: - It is independent of the App Engine SDK. If the SDK is not found, it sets fallbacks to be used outside of GAE. -- It supports threaded environments, using the :ref:`api.extras.local_app` - module. +- It supports threaded environments, using the module :ref:`api.extras.local`. - All webapp2_extras modules are designed to be thread-safe. - It is compatible with ``WebOb`` 1.0 and superior, which fixes several bugs found in the version bundled with the SDK (which is of course supported as @@ -142,13 +141,12 @@ a handler to display a 'Hello, webapp2!' message. This will be our bootstrap file:: import webapp2 - from webapp2_extras import local_app class HelloWebapp2(webapp2.RequestHandler): def get(self): self.response.write('Hello, webapp2!') - app = local_app.WSGIApplication([ + app = webapp2.WSGIApplication([ ('/', HelloWebapp2), ], debug=True) @@ -159,9 +157,6 @@ file:: if __name__ == '__main__': main() -Notice that we use ``local_app.WSGIApplication``. This is a special version -of the WSGI application that is thread-safe. - Test your app ------------- diff --git a/setup.py b/setup.py index 56f5dec..b3d6d37 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( name = 'webapp2', - version = '1.8.1', + version = '2.0', license = 'Apache Software License', url = 'http://www.tipfy.org/', description = "Taking Google App Engine's webapp to the next level!", diff --git a/tests/extras_i18n_test.py b/tests/extras_i18n_test.py index c8cc01f..79dd570 100644 --- a/tests/extras_i18n_test.py +++ b/tests/extras_i18n_test.py @@ -33,7 +33,7 @@ def setUp(self): def test_translations_not_set(self): # We release it here because it is set on setUp() self.app.clear_globals() - self.assertRaises(AssertionError, i18n.gettext, 'foo') + self.assertRaises(RuntimeError, i18n.gettext, 'foo') def test_gettext(self): self.assertEqual(i18n.gettext('foo'), u'foo') diff --git a/tests/handler_test.py b/tests/handler_test.py index f381501..c4ea3ed 100644 --- a/tests/handler_test.py +++ b/tests/handler_test.py @@ -162,7 +162,6 @@ def get_redirect_url(handler, **kwargs): class TestHandler(test_base.BaseTestCase): def tearDown(self): super(TestHandler, self).tearDown() - app.clear_globals() app.error_handlers = {} def test_200(self): @@ -391,13 +390,13 @@ class Handler(webapp2.RequestHandler): def get(self, *args, **kwargs): pass - request = webapp2.Request.blank('http://localhost:80/') - request.route = webapp2.Route('') - request.route_args = tuple() - request.route_kwargs = {} - request.app = app - app.request = webapp2.WSGIApplication.request = request - handler = Handler(request, webapp2.Response()) + req = webapp2.Request.blank('http://localhost:80/') + req.route = webapp2.Route('') + req.route_args = tuple() + req.route_kwargs = {} + req.app = app + app.set_globals(app=app, request=req) + handler = Handler(req, webapp2.Response()) handler.app = app for func in (handler.uri_for,): @@ -431,8 +430,6 @@ def get(self, *args, **kwargs): self.assertEqual(func('route-test', _scheme='https', _full=False, year='2010', month='07', name='test'), 'https://localhost:80/2010/07/test') self.assertEqual(func('route-test', _scheme='https', _fragment='my-anchor', year='2010', month='07', name='test'), 'https://localhost:80/2010/07/test#my-anchor') - app.request = None - def test_extra_request_methods(self): allowed_methods_backup = app.allowed_methods webdav_methods = ('VERSION-CONTROL', 'UNLOCK', 'PROPFIND') diff --git a/tests/misc_test.py b/tests/misc_test.py index 5390429..4c029be 100644 --- a/tests/misc_test.py +++ b/tests/misc_test.py @@ -8,6 +8,7 @@ class TestMiscellaneous(test_base.BaseTestCase): + def test_abort(self): self.assertRaises(webob.exc.HTTPOk, webapp2.abort, 200) self.assertRaises(webob.exc.HTTPCreated, webapp2.abort, 201) @@ -118,6 +119,7 @@ def test_redirect_to(self): req = webapp2.Request.blank('/') req.app = app app.set_globals(app=app, request=req) + rsp = webapp2.redirect_to('home', _code=301, _body='Weee') self.assertEqual(rsp.status_int, 301) self.assertEqual(rsp.body, 'Weee') diff --git a/tests/test_base.py b/tests/test_base.py index c7dda67..fa8ccc2 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -61,15 +61,15 @@ def setUp(self): # Only when testing ndb. self.setup_context_cache() - #self._app = webapp2.WSGIApplication() + def tearDown(self): # This restores the original stubs so that tests do not interfere # with each other. self.testbed.deactivate() self.testbed.setup_env = self._orig_setup_env - - #self._app.clear_globals() + # Clear thread-local variables. + self.clear_globals() def setup_env(self, **kwargs): kwargs.setdefault('app_id', self.DEFAULT_APP_ID) @@ -91,3 +91,6 @@ def setup_context_cache(self): ctx = tasklets.get_context() ctx.set_cache_policy(lambda key: False) ctx.set_memcache_policy(lambda key: False) + + def clear_globals(self): + webapp2._local.__release_local__() diff --git a/webapp2.py b/webapp2.py index 88ca0e3..b681958 100755 --- a/webapp2.py +++ b/webapp2.py @@ -49,13 +49,20 @@ class webapp(object): RequestHandler = type('RequestHandler', (object,), {}) class util(object): - @staticmethod def _run(app): handlers.CGIHandler().run(app) - run_wsgi_app = run_bare_wsgi_app = _run + run_wsgi_app = run_bare_wsgi_app = staticmethod(_run) -__version_info__ = ('1', '8', '1') +try: + # Thread-safety support. + from webapp2_extras import local +except ImportError: # pragma: no cover + logging.warning("webapp2_extras.local is not available " + "so webapp2 won't be thread-safe!") + local = None + +__version_info__ = ('2', '0') __version__ = '.'.join(__version_info__) #: Base HTTP exception, set here as public interface. @@ -1435,25 +1442,33 @@ def __init__(self, routes=None, debug=False, config=None): def set_globals(self, app=None, request=None): """Registers the global variables for app and request. - App Engine doesn't support threading, so we just assign them directly - as class attributes of the :class:`WSGIApplication`. + If :mod:`webapp2_extras.local` is available the app and request + class attributes are assigned to a proxy object that returns them + using thread-local, making the application thread-safe. This can also + be used in environments that don't support threading. - For threaded environments, direct assignment must be replaced by - assigning to a proxy object that returns app and request using - thread-local. Check :class:`webapp2_extras.local_app.WSGIApplication` - for an example. + If :mod:`webapp2_extras.local` is not available app and request will + be assigned directly as class attributes. This should only be used + in non-threaded environments (like App Engine Python 2.5). :param app: A :class:`WSGIApplication` instance. :param request: A :class:`Request` instance. """ - WSGIApplication.app = WSGIApplication.active_instance = app - WSGIApplication.request = request + if local is not None: # pragma: no cover + _local.app = app + _local.request = request + else: # pragma: no cover + WSGIApplication.app = WSGIApplication.active_instance = app + WSGIApplication.request = request def clear_globals(self): """Clears global variables. See :meth:`set_globals.`""" - WSGIApplication.app = WSGIApplication.active_instance = \ + if local is not None: # pragma: no cover + _local.__release_local__() + else: # pragma: no cover + WSGIApplication.app = WSGIApplication.active_instance = None WSGIApplication.request = None def __call__(self, environ, start_response): @@ -1590,12 +1605,8 @@ def get_app(): :returns: A :class:`WSGIApplication` instance. - :raises: - ``AssertionError`` if the app is not set. """ - app = WSGIApplication.app - assert app is not None, 'WSGIApplication.app is not set.' - return app + return WSGIApplication.app def get_request(): @@ -1603,12 +1614,8 @@ def get_request(): :returns: A :class:`Request` instance. - :raises: - ``AssertionError`` if the request is not set. """ - request = WSGIApplication.request - assert request is not None, 'WSGIApplication.request is not set.' - return request + return WSGIApplication.request def uri_for(_name, _request=None, *args, **kwargs): @@ -1855,3 +1862,8 @@ def _get_route_variables(match, default_kwargs=None): Response.RequestClass = Request # Alias. _abort = abort +# Thread-safety support. +if local is not None: # pragma: no cover + _local = local.Local() + WSGIApplication.app = WSGIApplication.active_instance = _local('app') + WSGIApplication.request = _local('request') diff --git a/webapp2_extras/local_app.py b/webapp2_extras/local_app.py index 3ed5d22..9257428 100644 --- a/webapp2_extras/local_app.py +++ b/webapp2_extras/local_app.py @@ -3,45 +3,22 @@ webapp2_extras.local_app ~~~~~~~~~~~~~~~~~~~~~~~~ - This module implements a WSGIApplication adapted for threaded environments. + This module is deprecated. The functionality is now available + directly in webapp2. + + Previously it implemented a WSGIApplication adapted for threaded + environments. :copyright: 2011 by tipfy.org. :license: Apache Sotware License, see LICENSE for details. """ -import webapp2 - -from webapp2_extras import local - - -_local = local.Local() -_app_class = webapp2.WSGIApplication -_app_class.app = _app_class.active_instance = _local('app') -_app_class.request = _local('request') +import warnings +import webapp2 -class WSGIApplication(_app_class): - """A WSGIApplication for threaded environments. - - This allows webapp2 to be used in non-GAE servers. - """ - - def set_globals(self, app=None, request=None): - """Registers the global variables for app and request. - - This makes the WSGI application thread-safe: the variables are - assigned to a proxy object that returns app and request using - thread-local. - - :param app: - A :class:`webapp2.WSGIApplication` instance or None to remove it - from the globals. - :param request: - A :class:`webapp2.Request` instance or None to remove it from - the globals. - """ - _local.app = app - _local.request = request +warnings.warn(DeprecationWarning( + 'webapp2_extras.local_app is deprecated. webapp2.WSGIApplication is now ' + 'thread-safe by default when webapp2_extras.local is available.'), + stacklevel=1) - def clear_globals(self): - """Clears global variables. See :meth:`set_globals.`""" - _local.__release_local__() +WSGIApplication = webapp2.WSGIApplication