Skip to content

Commit b09de13

Browse files
committed
Create directories before initializing sessions
This makes sure that errors happening during session initialization (e.g. trying to restore corrupt session files) are handled properly.
1 parent 89a0fa5 commit b09de13

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

WebKit/Application.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def __init__(self, server, useSessionSweeper=True):
174174
# sessions, in case the loading of the sessions causes an exception.
175175
self._exceptionHandlerClass = ExceptionHandler
176176

177-
self.initSessions()
178177
self.makeDirs()
178+
self.initSessions()
179179

180180
URLParser.initApp(self)
181181
self._rootURLParser = URLParser.ContextParser(self)
@@ -238,8 +238,6 @@ def initSessions(self):
238238
if moduleName in (
239239
'Dynamic', 'File', 'Memcached', 'Memory', 'Redis', 'Shelve'):
240240
moduleName = 'Session%sStore' % moduleName
241-
self._sessionDir = self.serverSidePath(
242-
self.setting('SessionStoreDir') or 'Sessions')
243241
className = moduleName.rsplit('.', 1)[-1]
244242
try:
245243
exec 'from %s import %s' % (moduleName, className)
@@ -258,6 +256,8 @@ def makeDirs(self):
258256
self.setting('CacheDir') or 'Cache')
259257
self._errorMessagesDir = self.serverSidePath(
260258
self.setting('ErrorMessagesDir') or 'ErrorMsgs')
259+
self._sessionDir = self.serverSidePath(
260+
self.setting('SessionStoreDir') or 'Sessions')
261261
for path in (self.serverSidePath('Logs'),
262262
self._cacheDir, self._errorMessagesDir, self._sessionDir):
263263
if path and not os.path.exists(path):

0 commit comments

Comments
 (0)