[Python-modules-commits] [django-maintenancemode] 01/03: import django-maintenancemode_0.11.2.orig.tar.gz

Scott Kitterman kitterman at moszumanska.debian.org
Thu Nov 10 15:19:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch master
in repository django-maintenancemode.

commit b4c0e856970b7ccc1399a558e1491c6a82f51617
Author: Scott Kitterman <scott at kitterman.com>
Date:   Thu Nov 10 10:11:15 2016 -0500

    import django-maintenancemode_0.11.2.orig.tar.gz
---
 AUTHORS                                            |   3 +
 CHANGES                                            |  60 +++++++++
 LICENSE                                            |  31 +++++
 MANIFEST.in                                        |   5 +
 PKG-INFO                                           | 145 +++++++++++++++++++++
 README.rst                                         | 119 +++++++++++++++++
 django_maintenancemode.egg-info/PKG-INFO           | 145 +++++++++++++++++++++
 django_maintenancemode.egg-info/SOURCES.txt        |  23 ++++
 .../dependency_links.txt                           |   1 +
 django_maintenancemode.egg-info/not-zip-safe       |   1 +
 django_maintenancemode.egg-info/requires.txt       |   3 +
 django_maintenancemode.egg-info/top_level.txt      |   1 +
 maintenancemode/__init__.py                        |   1 +
 maintenancemode/conf.py                            |  17 +++
 maintenancemode/http.py                            |   7 +
 maintenancemode/management/__init__.py             |   0
 maintenancemode/management/commands/__init__.py    |   0
 maintenancemode/management/commands/maintenance.py |  32 +++++
 maintenancemode/middleware.py                      |  55 ++++++++
 maintenancemode/models.py                          |   0
 maintenancemode/utils.py                           |  43 ++++++
 maintenancemode/views.py                           |  35 +++++
 setup.cfg                                          |   8 ++
 setup.py                                           |  85 ++++++++++++
 24 files changed, 820 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..675150e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+django-maintenancemode is written by Remco Wendt <remco at maykinmedia.nl>
+
+Feel free to contact me by mail if you have any questions, or just want to say hi.
\ No newline at end of file
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..cf098d0
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,60 @@
+Changes
+=======
+
+0.11.2
+------
+
+- Getting ready for Django 1.10 release.
+- Dropped support for Django 1.3 and older.
+
+0.11.1
+------
+
+- Enable network specify in INTERNAL_IPS
+
+0.11.0
+------
+
+- Added management command to set maintenance mode on/off
+
+0.10.1
+------
+
+- Made sure the app runs on Django 1.8.
+
+0.10.0
+------
+
+- Got rid of dependency on setuptools
+- Added ability to exclude specific paths from maintenance mode with the
+  ``MAINTENANCE_IGNORE_URLS`` setting.
+- Use RequestContext when rending the ``503.html`` template.
+- Use tox for running the tests instead of buildout.
+- Made sure the app runs on Django 1.4.
+
+0.9.3
+-----
+
+- Minor documentation updates for the switch to github, expect more changes to follow soon.
+
+0.9.2
+-----
+
+- Fixed an issue with setuptools, thanks for reporting this ksato9700
+
+0.9.1
+-----
+
+- Tested django-maintenancemode with django-1.0 release (following the 1.0.X release branch)
+- Bundled buildout.cfg and bootstrap with the source version of the project, allowing repeatable buildout
+- The middleware now uses its own default config file, thanks to a patch by semente
+- Use INTERNAL_IPS to check for users that need access. user.is_staff will stay in place
+  for backwards incompatibility. Thanks for the idea Joshua Works
+- Have setup.py sdist only distribute maintenancemode itself, no longer distribute tests and buildout stuff
+- Use README and CHANGES in setup.py's long_description, stolen from Jeroen's djangorecipe :)
+- Updated the documentation and now use pypi as the documentation source (link there from google code)
+
+0.9
+-----
+
+First release
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..aca15e4
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+Copyright (c) 2008, Maykin Media
+Copyright (c) 2012, enn.io
+Copyright (c) 2015, Basil Shubin 
+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 author nor the names of other
+      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
+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.
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..787b747
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include AUTHORS
+include CHANGES
+include LICENSE
+include README.rst
+recursive-exclude maintenancemode test*
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..e7820f7
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,145 @@
+Metadata-Version: 1.1
+Name: django-maintenancemode
+Version: 0.11.2
+Summary: django-maintenancemode allows you to temporary shutdown your site for maintenance work
+Home-page: http://github.com/shanx/django-maintenancemode
+Author: Basil Shubin
+Author-email: basil.shubin at gmail.com
+License: BSD License
+Download-URL: https://github.com/shanx/django-maintenancemode/zipball/master
+Description: django-maintenancemode
+        ======================
+        
+        django-maintenancemode is a middleware that allows you to temporary shutdown
+        your site for maintenance work.
+        
+        Logged in users having staff credentials can still fully use
+        the site as can users visiting the site from an IP address defined in
+        Django's ``INTERNAL_IPS``.
+        
+        Authored by `Remco Wendt <https://github.com/shanx>`_, and some great `contributors <https://github.com/shanx/django-maintenancemode/contributors>`_.
+        
+        .. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg
+            :target: https://travis-ci.org/shanx/django-maintenancemode/
+        
+        How it works
+        ------------
+        
+        ``maintenancemode`` works the same way as handling 404 or 500 error in
+        Django work. It adds a ``handler503`` which you can override in your
+        main ``urls.py`` or you can add a ``503.html`` to your templates
+        directory.
+        
+        * If user is logged in and staff member, the maintenance page is
+          not displayed.
+        
+        * If user's IP is in ``INTERNAL_IPS``, the maintenance page is
+          not displayed.
+        
+        * To override the default view which is used if the maintenance mode
+          is enabled you can simply define a ``handler503`` variable in your
+          ROOT_URLCONF_, similar to how you would customize other `error handlers`_,
+          e.g. :
+        
+          .. code-block:: python
+        
+              handler503 = 'example.views.maintenance_mode'
+        
+        Installation
+        ------------
+        
+        1. Either checkout ``maintenancemode`` from GitHub, or install using pip :
+        
+           .. code-block:: bash
+        
+               pip install django-maintenancemode
+        
+        2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` :
+        
+           .. code-block:: python
+        
+               INSTALLED_APPS = (
+                   ...
+                   'maintenancemode',
+               )
+        
+        3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` :
+        
+           .. code-block:: python
+        
+               MIDDLEWARE_CLASSES = (
+                   ...
+                   'django.contrib.auth.middleware.AuthenticationMiddleware',
+                   'maintenancemode.middleware.MaintenanceModeMiddleware',
+               )                
+        
+        4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file :
+        
+           .. code-block:: python
+        
+               MAINTENANCE_MODE = True  # Setting this variable to ``True`` activates the middleware.
+        
+           or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command :
+        
+           .. code-block:: shell
+        
+               python ./manage.py maintenance <on|off>
+        
+        Please see ``example`` application. This application is used to
+        manually test the functionalities of this package. This also serves as
+        a good example...
+        
+        You need only Django 1.4 or above to run that. It might run on older
+        versions but that is not tested.
+        
+        Configuration
+        -------------
+        
+        There are various optional configuration options you can set in your ``settings.py``
+        
+        .. code-block:: python
+        
+            # Enable / disable maintenance mode.
+            # Default: False
+            MAINTENANCE_MODE = True  # or ``False`` and use ``maintenance`` command
+            
+            # Sequence of URL path regexes to exclude from the maintenance mode.
+            # Default: ()
+            MAINTENANCE_IGNORE_URLS = (
+                r'^/docs/.*',
+                r'^/contact'
+            )
+        
+        License
+        -------
+        
+        ``django-maintenancemode`` is released under the BSD license.
+        
+        .. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
+        .. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Web Environment
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+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.4
+Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
+Requires: Django (>=1.4.2)
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..192652a
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,119 @@
+django-maintenancemode
+======================
+
+django-maintenancemode is a middleware that allows you to temporary shutdown
+your site for maintenance work.
+
+Logged in users having staff credentials can still fully use
+the site as can users visiting the site from an IP address defined in
+Django's ``INTERNAL_IPS``.
+
+Authored by `Remco Wendt <https://github.com/shanx>`_, and some great `contributors <https://github.com/shanx/django-maintenancemode/contributors>`_.
+
+.. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg
+    :target: https://pypi.python.org/pypi/django-maintenancemode/
+
+.. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg
+    :target: https://pypi.python.org/pypi/django-maintenancemode/
+
+.. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg
+    :target: https://pypi.python.org/pypi/django-maintenancemode/
+
+.. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg
+    :target: https://travis-ci.org/shanx/django-maintenancemode/
+
+How it works
+------------
+
+``maintenancemode`` works the same way as handling 404 or 500 error in
+Django work. It adds a ``handler503`` which you can override in your
+main ``urls.py`` or you can add a ``503.html`` to your templates
+directory.
+
+* If user is logged in and staff member, the maintenance page is
+  not displayed.
+
+* If user's IP is in ``INTERNAL_IPS``, the maintenance page is
+  not displayed.
+
+* To override the default view which is used if the maintenance mode
+  is enabled you can simply define a ``handler503`` variable in your
+  ROOT_URLCONF_, similar to how you would customize other `error handlers`_,
+  e.g. :
+
+  .. code-block:: python
+
+      handler503 = 'example.views.maintenance_mode'
+
+Installation
+------------
+
+1. Either checkout ``maintenancemode`` from GitHub, or install using pip :
+
+   .. code-block:: bash
+
+       pip install django-maintenancemode
+
+2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` :
+
+   .. code-block:: python
+
+       INSTALLED_APPS = (
+           ...
+           'maintenancemode',
+       )
+
+3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` :
+
+   .. code-block:: python
+
+       MIDDLEWARE_CLASSES = (
+           ...
+           'django.contrib.auth.middleware.AuthenticationMiddleware',
+           'maintenancemode.middleware.MaintenanceModeMiddleware',
+       )                
+
+4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file :
+
+   .. code-block:: python
+
+       MAINTENANCE_MODE = True  # Setting this variable to ``True`` activates the middleware.
+
+   or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command :
+
+   .. code-block:: shell
+
+       python ./manage.py maintenance <on|off>
+
+Please see ``example`` application. This application is used to
+manually test the functionalities of this package. This also serves as
+a good example...
+
+You need only Django 1.4 or above to run that. It might run on older
+versions but that is not tested.
+
+Configuration
+-------------
+
+There are various optional configuration options you can set in your ``settings.py``
+
+.. code-block:: python
+
+    # Enable / disable maintenance mode.
+    # Default: False
+    MAINTENANCE_MODE = True  # or ``False`` and use ``maintenance`` command
+    
+    # Sequence of URL path regexes to exclude from the maintenance mode.
+    # Default: ()
+    MAINTENANCE_IGNORE_URLS = (
+        r'^/docs/.*',
+        r'^/contact'
+    )
+
+License
+-------
+
+``django-maintenancemode`` is released under the BSD license.
+
+.. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
+.. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views
diff --git a/django_maintenancemode.egg-info/PKG-INFO b/django_maintenancemode.egg-info/PKG-INFO
new file mode 100644
index 0000000..e7820f7
--- /dev/null
+++ b/django_maintenancemode.egg-info/PKG-INFO
@@ -0,0 +1,145 @@
+Metadata-Version: 1.1
+Name: django-maintenancemode
+Version: 0.11.2
+Summary: django-maintenancemode allows you to temporary shutdown your site for maintenance work
+Home-page: http://github.com/shanx/django-maintenancemode
+Author: Basil Shubin
+Author-email: basil.shubin at gmail.com
+License: BSD License
+Download-URL: https://github.com/shanx/django-maintenancemode/zipball/master
+Description: django-maintenancemode
+        ======================
+        
+        django-maintenancemode is a middleware that allows you to temporary shutdown
+        your site for maintenance work.
+        
+        Logged in users having staff credentials can still fully use
+        the site as can users visiting the site from an IP address defined in
+        Django's ``INTERNAL_IPS``.
+        
+        Authored by `Remco Wendt <https://github.com/shanx>`_, and some great `contributors <https://github.com/shanx/django-maintenancemode/contributors>`_.
+        
+        .. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg
+            :target: https://pypi.python.org/pypi/django-maintenancemode/
+        
+        .. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg
+            :target: https://travis-ci.org/shanx/django-maintenancemode/
+        
+        How it works
+        ------------
+        
+        ``maintenancemode`` works the same way as handling 404 or 500 error in
+        Django work. It adds a ``handler503`` which you can override in your
+        main ``urls.py`` or you can add a ``503.html`` to your templates
+        directory.
+        
+        * If user is logged in and staff member, the maintenance page is
+          not displayed.
+        
+        * If user's IP is in ``INTERNAL_IPS``, the maintenance page is
+          not displayed.
+        
+        * To override the default view which is used if the maintenance mode
+          is enabled you can simply define a ``handler503`` variable in your
+          ROOT_URLCONF_, similar to how you would customize other `error handlers`_,
+          e.g. :
+        
+          .. code-block:: python
+        
+              handler503 = 'example.views.maintenance_mode'
+        
+        Installation
+        ------------
+        
+        1. Either checkout ``maintenancemode`` from GitHub, or install using pip :
+        
+           .. code-block:: bash
+        
+               pip install django-maintenancemode
+        
+        2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` :
+        
+           .. code-block:: python
+        
+               INSTALLED_APPS = (
+                   ...
+                   'maintenancemode',
+               )
+        
+        3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` :
+        
+           .. code-block:: python
+        
+               MIDDLEWARE_CLASSES = (
+                   ...
+                   'django.contrib.auth.middleware.AuthenticationMiddleware',
+                   'maintenancemode.middleware.MaintenanceModeMiddleware',
+               )                
+        
+        4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file :
+        
+           .. code-block:: python
+        
+               MAINTENANCE_MODE = True  # Setting this variable to ``True`` activates the middleware.
+        
+           or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command :
+        
+           .. code-block:: shell
+        
+               python ./manage.py maintenance <on|off>
+        
+        Please see ``example`` application. This application is used to
+        manually test the functionalities of this package. This also serves as
+        a good example...
+        
+        You need only Django 1.4 or above to run that. It might run on older
+        versions but that is not tested.
+        
+        Configuration
+        -------------
+        
+        There are various optional configuration options you can set in your ``settings.py``
+        
+        .. code-block:: python
+        
+            # Enable / disable maintenance mode.
+            # Default: False
+            MAINTENANCE_MODE = True  # or ``False`` and use ``maintenance`` command
+            
+            # Sequence of URL path regexes to exclude from the maintenance mode.
+            # Default: ()
+            MAINTENANCE_IGNORE_URLS = (
+                r'^/docs/.*',
+                r'^/contact'
+            )
+        
+        License
+        -------
+        
+        ``django-maintenancemode`` is released under the BSD license.
+        
+        .. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
+        .. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Web Environment
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+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.4
+Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
+Requires: Django (>=1.4.2)
diff --git a/django_maintenancemode.egg-info/SOURCES.txt b/django_maintenancemode.egg-info/SOURCES.txt
new file mode 100644
index 0000000..0931495
--- /dev/null
+++ b/django_maintenancemode.egg-info/SOURCES.txt
@@ -0,0 +1,23 @@
+AUTHORS
+CHANGES
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+django_maintenancemode.egg-info/PKG-INFO
+django_maintenancemode.egg-info/SOURCES.txt
+django_maintenancemode.egg-info/dependency_links.txt
+django_maintenancemode.egg-info/not-zip-safe
+django_maintenancemode.egg-info/requires.txt
+django_maintenancemode.egg-info/top_level.txt
+maintenancemode/__init__.py
+maintenancemode/conf.py
+maintenancemode/http.py
+maintenancemode/middleware.py
+maintenancemode/models.py
+maintenancemode/utils.py
+maintenancemode/views.py
+maintenancemode/management/__init__.py
+maintenancemode/management/commands/__init__.py
+maintenancemode/management/commands/maintenance.py
\ No newline at end of file
diff --git a/django_maintenancemode.egg-info/dependency_links.txt b/django_maintenancemode.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_maintenancemode.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/django_maintenancemode.egg-info/not-zip-safe b/django_maintenancemode.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_maintenancemode.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/django_maintenancemode.egg-info/requires.txt b/django_maintenancemode.egg-info/requires.txt
new file mode 100644
index 0000000..d4711ef
--- /dev/null
+++ b/django_maintenancemode.egg-info/requires.txt
@@ -0,0 +1,3 @@
+django>=1.4.2
+django-appconf
+ipy
diff --git a/django_maintenancemode.egg-info/top_level.txt b/django_maintenancemode.egg-info/top_level.txt
new file mode 100644
index 0000000..572a6df
--- /dev/null
+++ b/django_maintenancemode.egg-info/top_level.txt
@@ -0,0 +1 @@
+maintenancemode
diff --git a/maintenancemode/__init__.py b/maintenancemode/__init__.py
new file mode 100644
index 0000000..2b3823f
--- /dev/null
+++ b/maintenancemode/__init__.py
@@ -0,0 +1 @@
+__version__ = '0.11.2'
diff --git a/maintenancemode/conf.py b/maintenancemode/conf.py
new file mode 100644
index 0000000..c59b0f7
--- /dev/null
+++ b/maintenancemode/conf.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+import os
+
+from django.conf import settings  # pylint: disable=W0611
+from appconf import AppConf
+
+
+class MaintenanceSettings(AppConf):
+    IGNORE_URLS = ()
+    LOCKFILE_PATH = os.path.join(
+        os.path.abspath(os.path.dirname(__file__)), 'maintenance.lock')
+    MODE = False
+
+    class Meta:
+        prefix = 'maintenance'
+        holder = 'maintenancemode.conf.settings'
diff --git a/maintenancemode/http.py b/maintenancemode/http.py
new file mode 100644
index 0000000..2e675e8
--- /dev/null
+++ b/maintenancemode/http.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+from django.http import HttpResponse
+
+
+class HttpResponseTemporaryUnavailable(HttpResponse):
+    status_code = 503
diff --git a/maintenancemode/management/__init__.py b/maintenancemode/management/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/maintenancemode/management/commands/__init__.py b/maintenancemode/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/maintenancemode/management/commands/maintenance.py b/maintenancemode/management/commands/maintenance.py
new file mode 100644
index 0000000..67117c1
--- /dev/null
+++ b/maintenancemode/management/commands/maintenance.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+
+from django.core.management.base import BaseCommand, CommandError
+
+from maintenancemode import utils as maintenance
+
+
+class Command(BaseCommand):
+    opts = ('on', 'off', 'activate', 'deactivate')
+
+    def add_arguments(self, parser):
+        parser.add_argument('command', nargs='?', help='|'.join(self.opts))
+
+    def handle(self, *args, **options):
+        command = options.get('command', args[0] if len(args) > 0 else None)
+        verbosity = int(options.get('verbosity'))
+
+        if command is not None:
+            if command.lower() in ('on', 'activate'):
+                maintenance.activate()
+                if verbosity > 0:
+                    self.stdout.write(
+                        "Maintenance mode was activated succesfully")
+            elif command.lower() in ('off', 'deactivate'):
+                maintenance.deactivate()
+                if verbosity > 0:
+                    self.stdout.write(
+                        "Maintenance mode was deactivated succesfully")
+
+        if command not in self.opts:
+            raise CommandError(
+                "Allowed commands are: %s" % '|'.join(self.opts))
diff --git a/maintenancemode/middleware.py b/maintenancemode/middleware.py
new file mode 100644
index 0000000..dd5234a
--- /dev/null
+++ b/maintenancemode/middleware.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+
+import re
+import django
+
+from django.conf import urls
+from django.core import urlresolvers
+
+from .conf import settings
+from . import utils as maintenance
+
+urls.handler503 = 'maintenancemode.views.temporary_unavailable'
+urls.__all__.append('handler503')
+
+IGNORE_URLS = tuple([re.compile(u) for u in settings.MAINTENANCE_IGNORE_URLS])
+
+
+class MaintenanceModeMiddleware(object):
+
+    def process_request(self, request):
+        # Allow access if middleware is not activated
+        if not (settings.MAINTENANCE_MODE or maintenance.status()):
+            return None
+
+        INTERNAL_IPS = maintenance.IPList(settings.INTERNAL_IPS)
+
+        # Preferentially check HTTP_X_FORWARDED_FOR b/c a proxy
+        # server might have obscured REMOTE_ADDR
+        for ip in request.META.get('HTTP_X_FORWARDED_FOR', '').split(','):
+            if ip.strip() in INTERNAL_IPS:
+                return None
+
+        # Allow access if remote ip is in INTERNAL_IPS
+        if request.META.get('REMOTE_ADDR') in INTERNAL_IPS:
+            return None
+
+        # Allow access if the user doing the request is logged in and a
+        # staff member.
+        if hasattr(request, 'user') and request.user.is_staff:
+            return None
+
+        # Check if a path is explicitly excluded from maintenance mode
+        for url in IGNORE_URLS:
+            if url.match(request.path_info):
+                return None
+
+        # Otherwise show the user the 503 page
+        resolver = urlresolvers.get_resolver(None)
+
+        if django.VERSION < (1, 8):
+            callback, param_dict = resolver._resolve_special('503')
+        else:
+            callback, param_dict = resolver.resolve_error_handler('503')
+
+        return callback(request, **param_dict)
diff --git a/maintenancemode/models.py b/maintenancemode/models.py
new file mode 100644
index 0000000..e69de29
diff --git a/maintenancemode/utils.py b/maintenancemode/utils.py
new file mode 100644
index 0000000..d4b7253
--- /dev/null
+++ b/maintenancemode/utils.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+
+import os
+
+from .conf import settings
+
+
+class IPList(list):
+    """Stolen from https://djangosnippets.org/snippets/1362/"""
+
+    def __init__(self, ips):
+        try:
+            from IPy import IP
+            for ip in ips:
+                self.append(IP(ip))
+        except ImportError:
+            pass
+
+    def __contains__(self, ip):
+        try:
+            for net in self:
+                if ip in net:
+                    return True
+        except:
+            pass
+        return False
+
+
+def activate():
+    try:
+        open(settings.MAINTENANCE_LOCKFILE_PATH, 'ab', 0).close()
+    except OSError:
+        pass  # shit happens
+
+
+def deactivate():
+    if os.path.isfile(settings.MAINTENANCE_LOCKFILE_PATH):
+        os.remove(settings.MAINTENANCE_LOCKFILE_PATH)
+
+
+def status():
+    return settings.MAINTENANCE_MODE or os.path.isfile(
+        settings.MAINTENANCE_LOCKFILE_PATH)
diff --git a/maintenancemode/views.py b/maintenancemode/views.py
new file mode 100644
index 0000000..a45e873
--- /dev/null
+++ b/maintenancemode/views.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+
+import django
+
+if django.get_version() >= '1.8':
+    from django.template.loader import render_to_string
+else:
+    from django.template import loader, RequestContext
+
+    def render_to_string(template_name, context=None, request=None):
+        context_instance = RequestContext(request) if request else None
+
+        return loader.render_to_string(
+            template_name, context, context_instance)
+
+from . import http
+
+
+def temporary_unavailable(request, template_name='503.html'):
+    """
+    Default 503 handler, which looks for the requested URL in the
+    redirects table, redirects if found, and displays 404 page if not
+    redirected.
+
+    Templates: ``503.html``
+    Context:
+        request_path
+            The path of the requested URL (e.g., '/app/pages/bad_page/')
+
+    """
+    context = {
+        'request_path': request.path,
+    }
+    return http.HttpResponseTemporaryUnavailable(
+        render_to_string(template_name, context))
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..6c71b61
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,8 @@
+[wheel]
+universal = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..fc5c2a0
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+import codecs
+import subprocess
+
+from setuptools import setup, find_packages
+from setuptools.command.test import test as TestCommand
+
+
+class TestRunner(TestCommand):
+    user_options = []
+
+    def run(self):
+        raise SystemExit(subprocess.call([sys.executable, 'runtests.py']))
+
+
+def read(*parts):
+    file_path = os.path.join(os.path.dirname(__file__), *parts)
+    return codecs.open(file_path, encoding='utf-8').read()
+
+
+def find_version(*parts):
+    version_file = read(*parts)
+    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
+    if version_match:
+        return str(version_match.group(1))
+    raise RuntimeError("Unable to find version string.")
+
+
+setup(
+    name='django-maintenancemode',
+    version=find_version('maintenancemode', '__init__.py'),
+    license='BSD License',
+
+    install_requires=[
+        'django>=1.4.2',
+        'django-appconf',
+        'ipy',
+    ],
+    requires=[
+        'Django (>=1.4.2)',
+    ],
+
+    description="django-maintenancemode allows you to temporary shutdown your site for maintenance work",
+    long_description=read('README.rst'),
+
+    author='Remco Wendt',
+    author_email='remco at maykinmedia.nl',
+    
+    maintainer='Basil Shubin',
+    maintainer_email='basil.shubin at gmail.com',
+
+    url='http://github.com/shanx/django-maintenancemode',
+    download_url='https://github.com/shanx/django-maintenancemode/zipball/master',
+
+    packages=find_packages(exclude=('example*', '*.tests*')),
+    include_package_data=True,
+
+    tests_require=[
+    ],
+    cmdclass={
+        'test': TestRunner,
+    },
+
+    zip_safe=False,
+    classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Environment :: Web Environment',
+        'Framework :: Django',
+        'Intended Audience :: Developers',
+        'Intended Audience :: System Administrators',
+        '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.4',        
+        'Topic :: Internet :: WWW/HTTP',
+        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+    ],
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-maintenancemode.git



More information about the Python-modules-commits mailing list