[Python-modules-commits] [django-redis-sessions] 01/03: import django-redis-sessions_0.5.6.orig.tar.gz
Scott Kitterman
kitterman at moszumanska.debian.org
Thu Nov 10 22:12:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
kitterman pushed a commit to branch master
in repository django-redis-sessions.
commit ee66f08c2f68ae7a1f460000b17bc1ba9a9b00fa
Author: Scott Kitterman <scott at kitterman.com>
Date: Thu Nov 10 16:43:15 2016 -0500
import django-redis-sessions_0.5.6.orig.tar.gz
---
LICENSE.txt | 28 +++++
MANIFEST.in | 2 +
PKG-INFO | 71 ++++++++++++
README.md | 56 ++++++++++
django_redis_sessions.egg-info/PKG-INFO | 71 ++++++++++++
django_redis_sessions.egg-info/SOURCES.txt | 14 +++
.../dependency_links.txt | 1 +
django_redis_sessions.egg-info/not-zip-safe | 1 +
django_redis_sessions.egg-info/pbr.json | 1 +
django_redis_sessions.egg-info/requires.txt | 1 +
django_redis_sessions.egg-info/top_level.txt | 1 +
redis_sessions/__init__.py | 1 +
redis_sessions/session.py | 124 +++++++++++++++++++++
redis_sessions/settings.py | 22 ++++
setup.cfg | 5 +
setup.py | 32 ++++++
16 files changed, 431 insertions(+)
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..f07b69a
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,28 @@
+Copyright (c) 2010, Martin Rusev
+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.
\ No newline at end of file
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..3e677d0
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include README.md
+include LICENSE.txt
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..39af6c5
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,71 @@
+Metadata-Version: 1.1
+Name: django-redis-sessions
+Version: 0.5.6
+Summary: Redis Session Backend For Django
+Home-page: http://github.com/martinrusev/django-redis-sessions
+Author: Martin Rusev
+Author-email: martin at amon.cx
+License: BSD
+Description: django-redis-sessions
+ =======================
+ Redis database backend for your sessions
+
+
+ [![Build Status](https://travis-ci.org/martinrusev/django-redis-sessions.svg?branch=master)](https://travis-ci.org/martinrusev/django-redis-sessions)
+
+
+ Installation
+ ============
+
+ * Run `pip install django-redis-sessions` or alternatively download the tarball and run `python setup.py install`,
+
+ For Django < 1.4 run `pip install django-redis-sessions==0.3`
+
+ * Set `redis_sessions.session` as your session engine, like so:
+
+
+ ```
+ SESSION_ENGINE = 'redis_sessions.session'
+ ```
+
+ * Optional settings:
+
+ ```
+ SESSION_REDIS_HOST = 'localhost'
+ SESSION_REDIS_PORT = 6379
+ SESSION_REDIS_DB = 0
+ SESSION_REDIS_PASSWORD = 'password'
+ SESSION_REDIS_PREFIX = 'session'
+ SESSION_REDIS_SOCKET_TIMEOUT=1
+
+ # If you prefer domain socket connection,
+ # you can just add this line instead of SESSION_REDIS_HOST and SESSION_REDIS_PORT.
+
+ SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH = '/var/run/redis/redis.sock'
+
+ # Redis Sentinel
+ SESSION_REDIS_SENTINEL_LIST = [(host, port), (host, port), (host, port)]
+ SESSION_REDIS_SENTINEL_MASTER_ALIAS = 'sentinel-master'
+
+ ```
+
+
+
+ Tests
+ ============
+
+
+ ```
+ $ pip install django nose redis
+ # Make sure you have redis running on localhost:6379
+ $ nosetests
+ ```
+
+ # [Changelog](https://github.com/martinrusev/imbox/blob/master/CHANGELOG.md)
+Keywords: django,sessions,
+Platform: UNKNOWN
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Framework :: Django
+Classifier: Environment :: Web Environment
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b6a6d2a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,56 @@
+django-redis-sessions
+=======================
+Redis database backend for your sessions
+
+
+[![Build Status](https://travis-ci.org/martinrusev/django-redis-sessions.svg?branch=master)](https://travis-ci.org/martinrusev/django-redis-sessions)
+
+
+Installation
+============
+
+* Run `pip install django-redis-sessions` or alternatively download the tarball and run `python setup.py install`,
+
+For Django < 1.4 run `pip install django-redis-sessions==0.3`
+
+* Set `redis_sessions.session` as your session engine, like so:
+
+
+```
+SESSION_ENGINE = 'redis_sessions.session'
+```
+
+* Optional settings:
+
+```
+SESSION_REDIS_HOST = 'localhost'
+SESSION_REDIS_PORT = 6379
+SESSION_REDIS_DB = 0
+SESSION_REDIS_PASSWORD = 'password'
+SESSION_REDIS_PREFIX = 'session'
+SESSION_REDIS_SOCKET_TIMEOUT=1
+
+# If you prefer domain socket connection,
+# you can just add this line instead of SESSION_REDIS_HOST and SESSION_REDIS_PORT.
+
+SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH = '/var/run/redis/redis.sock'
+
+# Redis Sentinel
+SESSION_REDIS_SENTINEL_LIST = [(host, port), (host, port), (host, port)]
+SESSION_REDIS_SENTINEL_MASTER_ALIAS = 'sentinel-master'
+
+```
+
+
+
+Tests
+============
+
+
+```
+$ pip install django nose redis
+# Make sure you have redis running on localhost:6379
+$ nosetests
+```
+
+# [Changelog](https://github.com/martinrusev/imbox/blob/master/CHANGELOG.md)
\ No newline at end of file
diff --git a/django_redis_sessions.egg-info/PKG-INFO b/django_redis_sessions.egg-info/PKG-INFO
new file mode 100644
index 0000000..39af6c5
--- /dev/null
+++ b/django_redis_sessions.egg-info/PKG-INFO
@@ -0,0 +1,71 @@
+Metadata-Version: 1.1
+Name: django-redis-sessions
+Version: 0.5.6
+Summary: Redis Session Backend For Django
+Home-page: http://github.com/martinrusev/django-redis-sessions
+Author: Martin Rusev
+Author-email: martin at amon.cx
+License: BSD
+Description: django-redis-sessions
+ =======================
+ Redis database backend for your sessions
+
+
+ [![Build Status](https://travis-ci.org/martinrusev/django-redis-sessions.svg?branch=master)](https://travis-ci.org/martinrusev/django-redis-sessions)
+
+
+ Installation
+ ============
+
+ * Run `pip install django-redis-sessions` or alternatively download the tarball and run `python setup.py install`,
+
+ For Django < 1.4 run `pip install django-redis-sessions==0.3`
+
+ * Set `redis_sessions.session` as your session engine, like so:
+
+
+ ```
+ SESSION_ENGINE = 'redis_sessions.session'
+ ```
+
+ * Optional settings:
+
+ ```
+ SESSION_REDIS_HOST = 'localhost'
+ SESSION_REDIS_PORT = 6379
+ SESSION_REDIS_DB = 0
+ SESSION_REDIS_PASSWORD = 'password'
+ SESSION_REDIS_PREFIX = 'session'
+ SESSION_REDIS_SOCKET_TIMEOUT=1
+
+ # If you prefer domain socket connection,
+ # you can just add this line instead of SESSION_REDIS_HOST and SESSION_REDIS_PORT.
+
+ SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH = '/var/run/redis/redis.sock'
+
+ # Redis Sentinel
+ SESSION_REDIS_SENTINEL_LIST = [(host, port), (host, port), (host, port)]
+ SESSION_REDIS_SENTINEL_MASTER_ALIAS = 'sentinel-master'
+
+ ```
+
+
+
+ Tests
+ ============
+
+
+ ```
+ $ pip install django nose redis
+ # Make sure you have redis running on localhost:6379
+ $ nosetests
+ ```
+
+ # [Changelog](https://github.com/martinrusev/imbox/blob/master/CHANGELOG.md)
+Keywords: django,sessions,
+Platform: UNKNOWN
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Framework :: Django
+Classifier: Environment :: Web Environment
diff --git a/django_redis_sessions.egg-info/SOURCES.txt b/django_redis_sessions.egg-info/SOURCES.txt
new file mode 100644
index 0000000..daa21bc
--- /dev/null
+++ b/django_redis_sessions.egg-info/SOURCES.txt
@@ -0,0 +1,14 @@
+LICENSE.txt
+MANIFEST.in
+README.md
+setup.py
+django_redis_sessions.egg-info/PKG-INFO
+django_redis_sessions.egg-info/SOURCES.txt
+django_redis_sessions.egg-info/dependency_links.txt
+django_redis_sessions.egg-info/not-zip-safe
+django_redis_sessions.egg-info/pbr.json
+django_redis_sessions.egg-info/requires.txt
+django_redis_sessions.egg-info/top_level.txt
+redis_sessions/__init__.py
+redis_sessions/session.py
+redis_sessions/settings.py
\ No newline at end of file
diff --git a/django_redis_sessions.egg-info/dependency_links.txt b/django_redis_sessions.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_redis_sessions.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/django_redis_sessions.egg-info/not-zip-safe b/django_redis_sessions.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_redis_sessions.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/django_redis_sessions.egg-info/pbr.json b/django_redis_sessions.egg-info/pbr.json
new file mode 100644
index 0000000..1a535c5
--- /dev/null
+++ b/django_redis_sessions.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": false, "git_version": "7be7b21"}
\ No newline at end of file
diff --git a/django_redis_sessions.egg-info/requires.txt b/django_redis_sessions.egg-info/requires.txt
new file mode 100644
index 0000000..8f9d6bf
--- /dev/null
+++ b/django_redis_sessions.egg-info/requires.txt
@@ -0,0 +1 @@
+redis>=2.4.10
diff --git a/django_redis_sessions.egg-info/top_level.txt b/django_redis_sessions.egg-info/top_level.txt
new file mode 100644
index 0000000..635be30
--- /dev/null
+++ b/django_redis_sessions.egg-info/top_level.txt
@@ -0,0 +1 @@
+redis_sessions
diff --git a/redis_sessions/__init__.py b/redis_sessions/__init__.py
new file mode 100644
index 0000000..8701e4d
--- /dev/null
+++ b/redis_sessions/__init__.py
@@ -0,0 +1 @@
+__version__ = '0.5.6'
diff --git a/redis_sessions/session.py b/redis_sessions/session.py
new file mode 100644
index 0000000..4841a7e
--- /dev/null
+++ b/redis_sessions/session.py
@@ -0,0 +1,124 @@
+import redis
+
+try:
+ from django.utils.encoding import force_unicode
+except ImportError: # Python 3.*
+ from django.utils.encoding import force_text as force_unicode
+from django.contrib.sessions.backends.base import SessionBase, CreateError
+from redis_sessions import settings
+
+
+# Avoid new redis connection on each request
+
+if settings.SESSION_REDIS_SENTINEL_LIST is not None:
+ from redis.sentinel import Sentinel
+
+ redis_server = Sentinel(
+ settings.SESSION_REDIS_SENTINEL_LIST,
+ socket_timeout=settings.SESSION_REDIS_SOCKET_TIMEOUT,
+ retry_on_timeout=settings.SESSION_REDIS_RETRY_ON_TIMEOUT,
+ db=getattr(settings, 'SESSION_REDIS_DB', 0),
+ password=getattr(settings, 'SESSION_REDIS_PASSWORD', None)
+ ).master_for(settings.SESSION_REDIS_SENTINEL_MASTER_ALIAS)
+
+elif settings.SESSION_REDIS_URL is not None:
+
+ redis_server = redis.StrictRedis.from_url(
+ settings.SESSION_REDIS_URL,
+ socket_timeout=settings.SESSION_REDIS_SOCKET_TIMEOUT
+ )
+elif settings.SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH is None:
+
+ redis_server = redis.StrictRedis(
+ host=settings.SESSION_REDIS_HOST,
+ port=settings.SESSION_REDIS_PORT,
+ socket_timeout=settings.SESSION_REDIS_SOCKET_TIMEOUT,
+ retry_on_timeout=settings.SESSION_REDIS_RETRY_ON_TIMEOUT,
+ db=settings.SESSION_REDIS_DB,
+ password=settings.SESSION_REDIS_PASSWORD
+ )
+else:
+
+ redis_server = redis.StrictRedis(
+ unix_socket_path=settings.SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH,
+ socket_timeout=settings.SESSION_REDIS_SOCKET_TIMEOUT,
+ retry_on_timeout=settings.SESSION_REDIS_RETRY_ON_TIMEOUT,
+ db=settings.SESSION_REDIS_DB,
+ password=settings.SESSION_REDIS_PASSWORD,
+ )
+
+
+class SessionStore(SessionBase):
+ """
+ Implements Redis database session store.
+ """
+ def __init__(self, session_key=None):
+ super(SessionStore, self).__init__(session_key)
+
+ self.server = redis_server
+
+ def load(self):
+ try:
+ session_data = self.server.get(
+ self.get_real_stored_key(self._get_or_create_session_key())
+ )
+ return self.decode(force_unicode(session_data))
+ except:
+ self._session_key = None
+ return {}
+
+ def exists(self, session_key):
+ return self.server.exists(self.get_real_stored_key(session_key))
+
+ def create(self):
+ while True:
+ self._session_key = self._get_new_session_key()
+
+ try:
+ self.save(must_create=True)
+ except CreateError:
+ # Key wasn't unique. Try again.
+ continue
+ self.modified = True
+ return
+
+ def save(self, must_create=False):
+ if self.session_key is None:
+ return self.create()
+ if must_create and self.exists(self._get_or_create_session_key()):
+ raise CreateError
+ data = self.encode(self._get_session(no_load=must_create))
+ if redis.VERSION[0] >= 2:
+ self.server.setex(
+ self.get_real_stored_key(self._get_or_create_session_key()),
+ self.get_expiry_age(),
+ data
+ )
+ else:
+ self.server.set(
+ self.get_real_stored_key(self._get_or_create_session_key()),
+ data
+ )
+ self.server.expire(
+ self.get_real_stored_key(self._get_or_create_session_key()),
+ self.get_expiry_age()
+ )
+
+ def delete(self, session_key=None):
+ if session_key is None:
+ if self.session_key is None:
+ return
+ session_key = self.session_key
+ try:
+ self.server.delete(self.get_real_stored_key(session_key))
+ except:
+ pass
+
+ def get_real_stored_key(self, session_key):
+ """Return the real key name in redis storage
+ @return string
+ """
+ prefix = settings.SESSION_REDIS_PREFIX
+ if not prefix:
+ return session_key
+ return ':'.join([prefix, session_key])
diff --git a/redis_sessions/settings.py b/redis_sessions/settings.py
new file mode 100644
index 0000000..5f49ae9
--- /dev/null
+++ b/redis_sessions/settings.py
@@ -0,0 +1,22 @@
+from django.conf import settings
+
+
+SESSION_REDIS_HOST = getattr(settings, 'SESSION_REDIS_HOST', 'localhost')
+SESSION_REDIS_PORT = getattr(settings, 'SESSION_REDIS_PORT', 6379)
+SESSION_REDIS_SOCKET_TIMEOUT = getattr(settings, 'SESSION_REDIS_SOCKET_TIMEOUT', 0.1)
+SESSION_REDIS_RETRY_ON_TIMEOUT = getattr(settings, 'SESSION_REDIS_RETRY_ON_TIMEOUT', False)
+SESSION_REDIS_DB = getattr(settings, 'SESSION_REDIS_DB', 0)
+SESSION_REDIS_PREFIX = getattr(settings, 'SESSION_REDIS_PREFIX', '')
+SESSION_REDIS_PASSWORD = getattr(settings, 'SESSION_REDIS_PASSWORD', None)
+SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH = getattr(
+ settings, 'SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH', None
+)
+SESSION_REDIS_URL = getattr(settings, 'SESSION_REDIS_URL', None)
+
+# should be on the format [(host, port), (host, port), (host, port)]
+SESSION_REDIS_SENTINEL_LIST = getattr(
+ settings, 'SESSION_REDIS_SENTINEL_LIST', None
+)
+SESSION_REDIS_SENTINEL_MASTER_ALIAS = getattr(
+ settings, 'SESSION_REDIS_SENTINEL_MASTER_ALIAS', None
+)
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[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..b212ec3
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,32 @@
+from setuptools import setup
+import os
+from redis_sessions import __version__
+
+def read(filename):
+ return open(os.path.join(os.path.dirname(__file__), filename)).read()
+
+packages = ['redis_sessions']
+
+
+setup(
+ name='django-redis-sessions',
+ version=__version__,
+ description= "Redis Session Backend For Django",
+ long_description=read("README.md"),
+ keywords='django, sessions,',
+ author='Martin Rusev',
+ author_email='martin at amon.cx',
+ url='http://github.com/martinrusev/django-redis-sessions',
+ license='BSD',
+ packages=packages,
+ zip_safe=False,
+ install_requires=['redis>=2.4.10'],
+ include_package_data=True,
+ classifiers=[
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 3",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ "Framework :: Django",
+ "Environment :: Web Environment",
+ ],
+)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-redis-sessions.git
More information about the Python-modules-commits
mailing list