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: [email protected]
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/56a0582f-5c43-24d3-0de8-50a4a2c7bc5a%40tuwien.ac.at.