gloun.tool.Expose cleans my session

15 views
Skip to first unread message

Martin Mosbeck

unread,
Aug 12, 2019, 11:20:06 PM8/12/19
to web...@googlegroups.com
Hi everyone,

I use gloun.tools.Expose to expose a folder, the base directory is built with
variables, that are saved in the session. But, gloun.tools.Expose cleans the
session at its init function.

Usecase:
User clicks a link with GET variables, this is a call to a function in a
controller. The controller takes the variables, puts them into the session and
exposes a directory based on these variables with gloun.tools.Expose. In this
exposed file view, the user clicks on a folder-link to traverse to a subfolder.
As this link is created by gloun.tools.Expose, no GET variables are set,
therefore the variables saved in the session should be used to build the base
directory.

Simplified code-snippet:

if not request.vars['UserId']:
UserId = session.viewUserId
else:
UserId = int(request.vars['UserId'])
session.viewUserId = UserId

if not request.vars['TaskNr']:
TaskNr = session.viewTaskNr
else:
TaskNr = int(request.vars['TaskNr'])
session.viewTaskNr = TaskNr

taskSubDir = "{0}/{1}/Task{2}".format(usersDir, UserId, TaskNr)
return dict(files=Expose(base=taskSubDir))
###########################################################################

But, gloun.tool.Expose cleans the session in its init function. Code in the
gloun/tools Expose __init__ function:

# why would this not be callable? but otherwise tests do not pass
if current.session and callable(current.session.forget):
current.session.forget()
############################################################################

So I get a FILE NOT FOUND error, when traversing to any subfolder via click in
the exposed file-view, as the session was cleared.

If I delete these lines from gloun.tools.Expose init function, everything works
as expected.

Is there any special reasons, why the session is cleaned when using
gloun.tools.Expose or is this an unintended behavior/bug or am I using Expose in
a way it was not intended? Or is there an other solution to my usecase , I am
missing?

Tested under version: Version 2.18.5-stable+timestamp.2019.04.08.04.22.03

Best & thanks

Martin Mosbeck

--
Martin Mosbeck

TU Wien
Gusshausstraße 25-29 / E384
1040 Vienna, Austria
Web: https://www.ict.tuwien.ac.at/en/
Email: martin....@tuwien.ac.at
Reply all
Reply to author
Forward
0 new messages