* Refix of storage, so it will be compatible with previous versions of UDS

* Added new "development" package to include stuff for development/debug stage
* Ported fix for RDP/TSRDP transports from 1.5 to trunk
This commit is contained in:
Adolfo Gómez 2014-06-03 12:26:32 +00:00
parent ce1a9b4b2f
commit 33c2cbe666
6 changed files with 60 additions and 14 deletions

View File

@ -136,6 +136,7 @@ encoding//src/uds/core/workers/ServiceCacheUpdater.py=utf-8
encoding//src/uds/core/workers/StatsCollector.py=utf-8
encoding//src/uds/core/workers/UserServiceCleaner.py=utf-8
encoding//src/uds/core/workers/__init__.py=utf-8
encoding//src/uds/development/middleware/__init__.py=utf-8
encoding//src/uds/dispatchers/__init__.py=utf-8
encoding//src/uds/dispatchers/guacamole/__init__.py=utf-8
encoding//src/uds/dispatchers/guacamole/urls.py=utf-8
@ -254,7 +255,12 @@ encoding//src/uds/services/__init__.py=utf-8
encoding//src/uds/templatetags/REST.py=utf-8
encoding//src/uds/templatetags/html5.py=utf-8
encoding//src/uds/tests/__init__.py=utf-8
encoding//src/uds/tests/core/__init__.py=utf-8
encoding//src/uds/tests/core/util/cache.py=utf-8
encoding//src/uds/tests/core/util/net.py=utf-8
encoding//src/uds/tests/core/util/storage.py=utf-8
encoding//src/uds/tests/web/__init__.py=utf-8
encoding//src/uds/tests/web/admin/auth/__init__.py=utf-8
encoding//src/uds/tests/web/auth/__init__.py=utf-8
encoding//src/uds/transports/HTML5RDP/HTML5RDP.py=utf-8
encoding//src/uds/transports/HTML5RDP/__init__.py=utf-8

View File

@ -55,9 +55,9 @@ class Storage(object):
def saveData(self, skey, data, attr1=None):
key = self.__getKey(skey)
if isinstance(data, str):
data = data.decode('utf-8')
data = data.encode('utf-8').encode(Storage.CODEC)
if isinstance(data, unicode):
data = data.encode('utf-8')
data = data.encode(Storage.CODEC)
attr1 = '' if attr1 == None else attr1
try:
dbStorage.objects.create(owner=self._owner, key=key, data=data, attr1=attr1)
@ -69,7 +69,7 @@ class Storage(object):
return self.saveData(skey, data)
def putPickle(self, skey, data, attr1=None):
return self.saveData(skey, cPickle.dumps(data).encode('base64'), attr1)
return self.saveData(skey, cPickle.dumps(data), attr1)
def updateData(self, skey, data, attr1=None):
self.saveData(skey, data, attr1)
@ -79,7 +79,7 @@ class Storage(object):
key = self.__getKey(skey)
logger.debug('Accesing to {0} {1}'.format(skey, key))
c = dbStorage.objects.get(pk=key)
return c.data.decode(Storage.CODEC).decode('utf-8')
return c.data.decode(Storage.CODEC)
except dbStorage.DoesNotExist:
logger.debug('key not found')
return None
@ -90,7 +90,7 @@ class Storage(object):
def getPickle(self, skey):
v = self.readData(skey)
if v is not None:
v = cPickle.loads(v.decode('base64'))
v = cPickle.loads(v)
return v
def remove(self, skey):

View File

View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 Virtual Cable S.L.
# 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 Virtual Cable S.L. 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 HOLDER 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.
from __future__ import unicode_literals
import logging
logger = logging.getLogger(__name__)
class RequestDebug(object):
"""
Add a X-UA-Compatible header to the response
This header tells to Internet Explorer to render page with latest
possible version or to use chrome frame if it is installed.
"""
def process_request(self, request):
logger.info('Request lang: {0}'.format(request.LANGUAGE_CODE))

View File

@ -184,10 +184,9 @@ class RDPTransport(Transport):
if self._useEmptyCreds is True:
username, password, domain = '', '', ''
if domain != '':
if domain.find('.') == -1: # Dotter domain form
username = username + '@' + domain
domain = ''
if '.' in domain: # Dotter domain form
username = username + '@' + domain
domain = ''
width, height = CommonPrefs.getWidthHeight(prefs)
depth = CommonPrefs.getDepth(prefs)

View File

@ -171,10 +171,9 @@ class TSRDPTransport(Transport):
if self._useEmptyCreds is True:
username, password, domain = '', '', ''
if domain != '':
if domain.find('.') == -1: # Dotter domain form
username = username + '@' + domain
domain = ''
if '.' in domain: # Dotter domain form
username = username + '@' + domain
domain = ''
width, height = CommonPrefs.getWidthHeight(prefs)
depth = CommonPrefs.getDepth(prefs)