store request in thread local data
This commit is contained in:
parent
9024ca99e1
commit
3bcc61880c
2 changed files with 13 additions and 4 deletions
|
@ -69,7 +69,7 @@ from loops.resource import Resource
|
||||||
from loops.security.common import canAccessObject, canListObject, canWriteObject
|
from loops.security.common import canAccessObject, canListObject, canWriteObject
|
||||||
from loops.type import ITypeConcept
|
from loops.type import ITypeConcept
|
||||||
from loops import util
|
from loops import util
|
||||||
from loops.util import _
|
from loops.util import _, saveRequest
|
||||||
from loops import version
|
from loops import version
|
||||||
from loops.versioning.interfaces import IVersionable
|
from loops.versioning.interfaces import IVersionable
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ class BaseView(GenericView, I18NView):
|
||||||
raise Unauthorized(str(self.contextInfo))
|
raise Unauthorized(str(self.contextInfo))
|
||||||
except ForbiddenAttribute: # ignore when testing
|
except ForbiddenAttribute: # ignore when testing
|
||||||
pass
|
pass
|
||||||
|
saveRequest(request)
|
||||||
|
|
||||||
def checkPermissions(self):
|
def checkPermissions(self):
|
||||||
return canAccessObject(self.context)
|
return canAccessObject(self.context)
|
||||||
|
|
14
util.py
14
util.py
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Utility functions.
|
Utility functions.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -28,6 +26,7 @@ from zope.app.intid.interfaces import IIntIds
|
||||||
from zope.interface import directlyProvides, directlyProvidedBy
|
from zope.interface import directlyProvides, directlyProvidedBy
|
||||||
from zope.i18nmessageid import MessageFactory
|
from zope.i18nmessageid import MessageFactory
|
||||||
from zope.schema import vocabulary
|
from zope.schema import vocabulary
|
||||||
|
from zope import thread
|
||||||
|
|
||||||
import cybertools
|
import cybertools
|
||||||
from loops.browser.util import html_quote
|
from loops.browser.util import html_quote
|
||||||
|
@ -134,3 +133,12 @@ def getLogDirectory(request=None):
|
||||||
return os.path.join(os.path.dirname(varDir), 'log')
|
return os.path.join(os.path.dirname(varDir), 'log')
|
||||||
|
|
||||||
|
|
||||||
|
# store thread-local stuff
|
||||||
|
|
||||||
|
local_data = thread.local()
|
||||||
|
|
||||||
|
def saveRequest(request):
|
||||||
|
local_data.request = request
|
||||||
|
|
||||||
|
def getRequest():
|
||||||
|
return local_data.request
|
||||||
|
|
Loading…
Add table
Reference in a new issue