fixed issue with sessions in db on GAE

This commit is contained in:
mdipierro
2016-07-17 04:18:56 -05:00
parent b6fc1b0809
commit 665e14186e
2 changed files with 20 additions and 19 deletions
+1 -1
View File
@@ -317,7 +317,7 @@ a:not(.btn):not(.noeffect):after {
.accordion>input {display:none} .accordion>input {display:none}
.accordion>input:checked ~ *:not(label) { .accordion>input:checked ~ *:not(label) {
max-height: 1000px !important; max-height: 1000px !important;
overflow:visible !important; overflow:hidden !important;
-webkit-transition: max-height .3s ease-in; -webkit-transition: max-height .3s ease-in;
transition: max-height .3s ease-in; transition: max-height .3s ease-in;
} }
+19 -18
View File
@@ -1192,28 +1192,29 @@ class Session(Storage):
def _try_store_in_file(self, request, response): def _try_store_in_file(self, request, response):
try: try:
if (not response.session_id or self._forget if (not response.session_id or
or self._unchanged(response)): not response.session_filename or
self._forget
or self._unchanged(response)):
# self.clear_session_cookies() # self.clear_session_cookies()
self.save_session_id_cookie()
return False return False
if response.session_new or not response.session_file: else:
# Tests if the session sub-folder exists, if not, create it if response.session_new or not response.session_file:
session_folder = os.path.dirname(response.session_filename) # Tests if the session sub-folder exists, if not, create it
if not os.path.exists(session_folder): session_folder = os.path.dirname(response.session_filename)
os.mkdir(session_folder) if not os.path.exists(session_folder):
response.session_file = recfile.open(response.session_filename, 'wb') os.mkdir(session_folder)
portalocker.lock(response.session_file, portalocker.LOCK_EX) response.session_file = recfile.open(response.session_filename, 'wb')
response.session_locked = True portalocker.lock(response.session_file, portalocker.LOCK_EX)
if response.session_file: response.session_locked = True
session_pickled = response.session_pickled or pickle.dumps(self, pickle.HIGHEST_PROTOCOL) if response.session_file:
response.session_file.write(session_pickled) session_pickled = response.session_pickled or pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
response.session_file.truncate() response.session_file.write(session_pickled)
response.session_file.truncate()
return True
finally: finally:
self._close(response) self._close(response)
self.save_session_id_cookie()
self.save_session_id_cookie()
return True
def _unlock(self, response): def _unlock(self, response):
if response and response.session_file and response.session_locked: if response and response.session_file and response.session_locked: