浏览代码

HUE-8530 [organization] Adding crequest module dependency

Romain 5 年之前
父节点
当前提交
e9e813e9ea

+ 22 - 0
desktop/core/ext-py/django-crequest-2018.5.11/AUTHORS.rst

@@ -0,0 +1,22 @@
+``django-crequest`` was originally created in middle 2012 at home, the bedroom
+division of the Alireza's place somewhere on planet earth maybe.
+
+The PRIMARY AUTHORS are (and/or have been):
+
+* Alireza Savand <alireza.savand@gmail.com>
+* François‎
+
+And here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
+people who have submitted patches, reported bugs, added translations, helped
+answer newbie questions, and generally made ``django-crequest`` that much better:
+
+* Alireza Savand <alireza.savand@gmail.com>
+* Richard Royal <richard.royal@coxinc.com>
+* Robert Rollins <rrollins@caltech.edu>
+* Alan Sergeant @asergeant01
+* Kouichi Nishizawa @koty
+
+A big THANK YOU goes to:
+
+* François‎ for convincing Alireza to start the project.
+* Guido van Rossum for creating Python.

+ 41 - 0
desktop/core/ext-py/django-crequest-2018.5.11/ChangeLog.rst

@@ -0,0 +1,41 @@
+2018.5.11
+=========
+----
+
+* Fixed #9: Error when installing on Python 2.
+
+
+2018.5.1
+========
+----
+
+* Fixed #7: process_exception() should not delete the request when using MIDDLEWARE.
+* Feature #5: Fix encoding error in the setup.py file.
+
+
+2016.3.16
+=========
+----
+
+* Add Django 1.10 support.
+
+
+2014.9.19
+=========
+----
+
+* Feature: Add packaging files: ``AUTHORS.rst``, ``ChangeLog.rst``, ``MANIFEST.in``.
+* Feature: Typos and fix ``README.rst`` spellings and remove unneeded files.
+* Feature: Enhance documentation.
+* Feature: Change release version numbering to date based.
+* Feature: Add ``Python 2``, ``Python 3``, ``PyPy`` support.
+
+
+1.0
+===
+
+----
+
+* Initial version and stable for production.
+
+

+ 27 - 0
desktop/core/ext-py/django-crequest-2018.5.11/LICENSE

@@ -0,0 +1,27 @@
+Copyright (c) 2012-2018 Alireza Savand
+All rights reserved.
+
+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.
+
+    * Neither the name of the authors nor the
+    names of its contributors may 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 HOLDERS 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.

+ 5 - 0
desktop/core/ext-py/django-crequest-2018.5.11/MANIFEST.in

@@ -0,0 +1,5 @@
+include README.rst
+include AUTHORS.rst
+include ChangeLog.rst
+include LICENSE
+

+ 128 - 0
desktop/core/ext-py/django-crequest-2018.5.11/PKG-INFO

@@ -0,0 +1,128 @@
+Metadata-Version: 1.1
+Name: django-crequest
+Version: 2018.5.11
+Summary: Middleware that makes the current request available from anywhere.
+Home-page: https://github.com/Alir3z4/django-crequest
+Author: Alireza Savand
+Author-email: alireza.savand@gmail.com
+License: Copyright (c) 2012-2018 Alireza Savand
+All rights reserved.
+
+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.
+
+    * Neither the name of the authors nor the
+    names of its contributors may 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 HOLDERS 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.
+
+Description-Content-Type: UNKNOWN
+Description: ===============
+        django-crequest
+        ===============
+        
+        .. contents:: 
+        
+        Overview
+        ========
+        - ``crequest`` takes care of current ``request`` in silent way.
+        - ``crequest`` will bring you current ``request`` object of your Django application from anywhere in your code.
+        
+        Installing
+        ==========
+        
+        ``django-crequest`` is available on http://pypi.python.org/pypi/django-crequest
+        So it can be installed it by pip::
+        
+            $ python pip install django-crequest
+        
+        Or you can grab the latest version tarball and ::
+        
+            $ python setup.py install
+        
+        To enable ``django-crequest`` in your project
+        
+        * Add ``crequest`` to *INSTALLED_APPS* in your **settings.py**
+        * Add ``crequest.middleware.CrequestMiddleware`` to ``MIDDLEWARE_CLASSES`` after the authentication and session middleware.
+        
+        
+        Supported Python versions
+        =========================
+        
+        ``django-crequest`` currently can be run on multiple python versions:
+        
+        * Python 2
+        * Python 3
+        * PyPy
+        
+        
+        How to use
+        ==========
+        
+        First import the crequest's middleware::
+        
+            from crequest.middleware import CrequestMiddleware
+        
+        Get the current ``request`` ;)::
+        
+            current_request = CrequestMiddleware.get_request()
+        
+        Done.
+        
+        In depth & Complex details
+        ==========================
+        
+        Set the current request in UnKnown situations::
+        
+             CrequestMiddleware.set_request(request)
+        
+        Return *iam_request* if there is no current request::
+        
+            CrequestMiddleware.get_request(iam_request)
+        
+        And finally delete::
+        
+            CrequestMiddleware.del_request()
+        
+        The middleware automatically sets/deletes the current request for HTTP requests.
+        For other uses (management commands, scripts), you will need to do this yourself.
+        
+        
+Keywords: django,request,web
+Platform: OS Independent
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Development Status :: 6 - Mature
+Classifier: Environment :: Web Environment
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.0
+Classifier: Programming Language :: Python :: 3.1
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries
+Provides: crequest

+ 70 - 0
desktop/core/ext-py/django-crequest-2018.5.11/README.rst

@@ -0,0 +1,70 @@
+===============
+django-crequest
+===============
+
+.. contents:: 
+
+Overview
+========
+- ``crequest`` takes care of current ``request`` in silent way.
+- ``crequest`` will bring you current ``request`` object of your Django application from anywhere in your code.
+
+Installing
+==========
+
+``django-crequest`` is available on http://pypi.python.org/pypi/django-crequest
+So it can be installed it by pip::
+
+    $ python pip install django-crequest
+
+Or you can grab the latest version tarball and ::
+
+    $ python setup.py install
+
+To enable ``django-crequest`` in your project
+
+* Add ``crequest`` to *INSTALLED_APPS* in your **settings.py**
+* Add ``crequest.middleware.CrequestMiddleware`` to ``MIDDLEWARE_CLASSES`` after the authentication and session middleware.
+
+
+Supported Python versions
+=========================
+
+``django-crequest`` currently can be run on multiple python versions:
+
+* Python 2
+* Python 3
+* PyPy
+
+
+How to use
+==========
+
+First import the crequest's middleware::
+
+    from crequest.middleware import CrequestMiddleware
+
+Get the current ``request`` ;)::
+
+    current_request = CrequestMiddleware.get_request()
+
+Done.
+
+In depth & Complex details
+==========================
+
+Set the current request in UnKnown situations::
+
+     CrequestMiddleware.set_request(request)
+
+Return *iam_request* if there is no current request::
+
+    CrequestMiddleware.get_request(iam_request)
+
+And finally delete::
+
+    CrequestMiddleware.del_request()
+
+The middleware automatically sets/deletes the current request for HTTP requests.
+For other uses (management commands, scripts), you will need to do this yourself.
+

+ 1 - 0
desktop/core/ext-py/django-crequest-2018.5.11/crequest/__init__.py

@@ -0,0 +1 @@
+__version__ = '2018.5.11'

+ 49 - 0
desktop/core/ext-py/django-crequest-2018.5.11/crequest/middleware.py

@@ -0,0 +1,49 @@
+import threading
+try:
+    from django.utils.deprecation import MiddlewareMixin
+except ImportError:
+    MiddlewareMixin = object
+
+
+class CrequestMiddleware(MiddlewareMixin):
+    """
+    Provides storage for the "current" request object, so that code anywhere
+    in your project can access it, without it having to be passed to that code
+    from the view.
+    """
+    _requests = {}
+
+    def process_request(self, request):
+        """
+        Store the current request.
+        """
+        self.__class__.set_request(request)
+
+    def process_response(self, request, response):
+        """
+        Delete the current request to avoid leaking memory.
+        """
+        self.__class__.del_request()
+        return response
+
+    @classmethod
+    def get_request(cls, default=None):
+        """
+        Retrieve the request object for the current thread, or the optionally
+        provided default if there is no current request.
+        """
+        return cls._requests.get(threading.current_thread(), default)
+
+    @classmethod
+    def set_request(cls, request):
+        """
+        Save the given request into storage for the current thread.
+        """
+        cls._requests[threading.current_thread()] = request
+
+    @classmethod
+    def del_request(cls):
+        """
+        Delete the request that was stored for the current thread.
+        """
+        cls._requests.pop(threading.current_thread(), None)

+ 4 - 0
desktop/core/ext-py/django-crequest-2018.5.11/setup.cfg

@@ -0,0 +1,4 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+

+ 41 - 0
desktop/core/ext-py/django-crequest-2018.5.11/setup.py

@@ -0,0 +1,41 @@
+from setuptools import setup, find_packages
+
+setup(
+    name='django-crequest',
+    version=__import__('crequest').__version__,
+    description='Middleware that makes the current request available from anywhere.',
+    long_description=open('README.rst').read(),
+    license=open('LICENSE').read(),
+    author='Alireza Savand',
+    author_email='alireza.savand@gmail.com',
+    url='https://github.com/Alir3z4/django-crequest',
+    packages=find_packages(exclude=['django_crequest']),
+    install_requires=['Django>=1.2'],
+    keywords=[
+        'django',
+        'request',
+        'web'
+    ],
+    platforms='OS Independent',
+    provides=['crequest',],
+    classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        "Development Status :: 6 - Mature",
+        "Environment :: Web Environment",
+        "Framework :: Django",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.0",
+        "Programming Language :: Python :: 3.1",
+        "Programming Language :: Python :: 3.2",
+        "Programming Language :: Python :: 3.3",
+        "Programming Language :: Python :: 3.4",
+        "Topic :: Software Development",
+        "Topic :: Software Development :: Libraries",
+    ],
+)

+ 1 - 0
desktop/core/requirements_py3.txt

@@ -21,6 +21,7 @@ django-auth-ldap==1.3.0
 django-axes==2.2.0
 django-celery-beat==1.4.0
 django_celery_results==1.0.4
+django-crequest==2018.5.11
 django-debug-panel==0.8.3
 django-debug-toolbar==1.9.1
 django-extensions==1.8.0