From ec7fa0eea3a86f2c6712ed242744d3710a1dc770 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Mon, 12 Jan 2015 21:58:21 +0100 Subject: [PATCH 1/2] Install all portable packages from requirements_production.txt. --- README.rst | 6 ++--- extras/win32-portable/create_portable.txt | 23 ++++--------------- extras/win32-portable/install-requirements.py | 12 ++++++++++ 3 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 extras/win32-portable/install-requirements.py diff --git a/README.rst b/README.rst index b8b68848d..fae94aa7a 100644 --- a/README.rst +++ b/README.rst @@ -86,14 +86,14 @@ portable version you should observe the following install steps.* and Setuptools on your system. a. Download and run the `Python 32-bit MSI installer - `_. Note + `_. Note that the 32-bit MSI installer is required even on a 64-bit Windows system. If you use the 64-bit MSI installer, step 3 of this instruction will fail unless you installed the package reportlab manually. b. Add python directories to PATH (via Control Panel > System > - Advanced): ``";C:\\Python27;C:\\Python27\\Scripts"``. Note that the path + Advanced): ``";C:\Python27;C:\Python27\Scripts"``. Note that the path can differ if you customized the install of Python in the first step. c. Download and run (via double click) the last `install script @@ -110,7 +110,7 @@ portable version you should observe the following install steps.* To install Virtual Python Environment builder, open command line (cmd) and run:: - > easy_install https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.6.tar.gz + > easy_install https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.5.tar.gz Create your OpenSlides directory, change to it, setup and activate the virtual environment:: diff --git a/extras/win32-portable/create_portable.txt b/extras/win32-portable/create_portable.txt index a6d2edbfd..a7138c19b 100644 --- a/extras/win32-portable/create_portable.txt +++ b/extras/win32-portable/create_portable.txt @@ -5,34 +5,21 @@ How to create a new portable Windows distribution of OpenSlides: Follow the instructions in the README, section III (Windows installation), step 1. -2. Install all required python packages (see requirements_production.txt): +2. Install all required python packages from requirements_production.txt: + (Note: You have to use 'easy_install -Z $PACKAGENAME') - easy_install -Z "django<1.7" ^ - backports.ssl_match_hostname ^ - "beautifulsoup4<4.4" ^ - "bleach<1.5" ^ - "django-ckeditor-updated<4.3" ^ - "django-haystack<2.2" ^ - "django-mptt<0.7" ^ - "jsonfield<0.10" ^ - "natsort<3.3" ^ - "reportlab<2.8" ^ - "roman<2.1" ^ - "sockjs_tornado<1.1" ^ - "tornado<3.3" ^ - "whoosh<2.6" ^ - "setuptools<3.7" + python install-requirements.py 3. Install pywin32 from binary installer: - http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download + http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win32-py2.7.exe/download Pywin32 is used to update the version resource of the prebuild openslides.exe. It is not strictly required but at least for published releases it is highly advisable. 4. Install wxPython from binary installer: - http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.12.1-py27.exe + http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/wxPython2.8-win32-unicode-2.8.12.1-py27.exe/download WxPython is required to build the OpenSlides GUI frontend. diff --git a/extras/win32-portable/install-requirements.py b/extras/win32-portable/install-requirements.py new file mode 100644 index 000000000..c2dfaa3c2 --- /dev/null +++ b/extras/win32-portable/install-requirements.py @@ -0,0 +1,12 @@ +import os + +f = open("../../requirements_production.txt") +reqs = f.read().split("\n") + +for req in reqs: + # ignore comments or pip options + if req.startswith('--') or req.startswith('#'): + continue + # ignore blank lines + if len(req) > 0: + os.system('easy_install -Z -U "%s"' % req) From fd266a4e45e2963403fb331356918c4e2176f392 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Tue, 13 Jan 2015 12:53:05 +0100 Subject: [PATCH 2/2] Fixed AttributeError in chatbox on_open method. Fixed TODO and updated get session method for session key. --- openslides/core/chatbox.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/openslides/core/chatbox.py b/openslides/core/chatbox.py index be5d0b728..614380465 100644 --- a/openslides/core/chatbox.py +++ b/openslides/core/chatbox.py @@ -3,8 +3,9 @@ from datetime import datetime from django.conf import settings -from django.contrib.sessions.models import Session from django.utils.html import urlize +from django.utils.importlib import import_module + from sockjs.tornado import SockJSConnection @@ -20,22 +21,25 @@ class ChatboxSocketHandler(SockJSConnection): """ from openslides.participant.models import User - # TODO: Use the django way to get the session to be compatible with - # other auth-backends; see comment in pull request #1220: - # https://github.com/OpenSlides/OpenSlides/pull/1220#discussion_r11565705 - session_key = info.get_cookie(settings.SESSION_COOKIE_NAME).value - session = Session.objects.get(session_key=session_key) + # get the session (compatible with other auth-backends) + engine = import_module(settings.SESSION_ENGINE) try: - self.user = User.objects.get(pk=session.get_decoded().get('_auth_user_id')) + session_key = info.get_cookie(settings.SESSION_COOKIE_NAME).value + session = engine.SessionStore(session_key) + pk = session.get_decoded().get('_auth_user_id') + except AttributeError: + return False + + try: + self.user = User.objects.get(pk) except User.DoesNotExist: - return_value = False + return False + + if self.user.has_perm('core.can_use_chat'): + self.clients.add(self) + return True else: - if self.user.has_perm('core.can_use_chat'): - self.clients.add(self) - return_value = True - else: - return_value = False - return return_value + return False def on_message(self, message): """