Commit cf513d62 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Fix „No workspace selected“ bug by updating the workspace tool.

parent 6c519ba2
......@@ -118,8 +118,7 @@ class Server(object):
'tools.private_parameters.on': True,
'tools.user.on': True,
'tools.user.redirect_url': vispa.url.dynamic('/login'),
'tools.workspace.on': True,
'tools.workspace.redirect_url': vispa.url.dynamic('/workspace'),
'tools.workspace.on': False,
'tools.sessions.on': True,
'tools.sessions.storage_type': 'file',
'tools.sessions.storage_path': vispa.datapath('sessions'),
......@@ -129,6 +128,9 @@ class Server(object):
'tools.gzip.mime_types': ['text/html', 'text/css', 'application/x-javascript', 'application/json'],
'tools.render.common_data': {'base_dynamic': base_dynamic, 'base_static': base_static},
},
'/extensions': {
'tools.workspace.on': True
},
'/static': {
'tools.db.on': False,
'tools.user.on': False,
......
......@@ -9,38 +9,30 @@ logger = logging.getLogger(__name__)
class WorkspaceTool(cherrypy.Tool):
def __init__(self):
cherrypy.Tool.__init__(self, "before_handler",
self._fetch, priority=70)
cherrypy.Tool.__init__(self, "before_handler", self.before_handler,
priority=70)
def _setup(self):
cherrypy.Tool._setup(self)
def _fetch(self, path=None, **conf):
def before_handler(self, **conf):
request = cherrypy.request
db = cherrypy.request.db
db = request.db
redir_path = path
request.workspace = None
# is at least one workspace connected?
wid = request.private_params.get("_workspaceId", None)
wid = wid or vispa.config("workspace", "default_workspace_id", None)
if not wid:
logger.debug('No Workspace selected!')
if redir_path:
raise cherrypy.HTTPRedirect(redir_path)
else:
raise cherrypy.HTTPError(message="No Workspace selected!")
workspace = Workspace.get_by_id(db, wid)
if not isinstance(workspace, Workspace):
msg = 'Selected Workspace (%s) not found!' % wid
logger.debug(msg)
if redir_path:
raise cherrypy.HTTPRedirect(redir_path)
else:
raise cherrypy.HTTPError(message=msg)
logger.debug('Workspace: %s (%d)' % (workspace.name, workspace.id))
request.workspace = workspace
if wid is None:
logger.debug("No workspace selected")
else:
workspace = Workspace.get_by_id(db, wid)
if not isinstance(workspace, Workspace):
logger.debug("Selected Workspace (%s) not found" % wid)
else:
logger.debug("Workspace: %s (%d)" %
(workspace.name, workspace.id))
request.workspace = workspace
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment