Commit ac404fd7 authored by Kevin Deldycke's avatar Kevin Deldycke

Klaus : Patch CookieCrumbler to remove "?came_from" from getLoginUrl (called...

Klaus : Patch CookieCrumbler to remove "?came_from" from getLoginUrl (called by request.unauthorized).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3892 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 021ef0d0
...@@ -705,15 +705,15 @@ TransitionDefinition.getAvailableScriptIds = ERP5TransitionDefinition.getAvailab ...@@ -705,15 +705,15 @@ TransitionDefinition.getAvailableScriptIds = ERP5TransitionDefinition.getAvailab
# Adding commit_prepare to the zodb transaction # Adding commit_prepare to the zodb transaction
try: try:
from ZODB import Transaction from ZODB import Transaction
hosed = Transaction.hosed hosed = Transaction.hosed
free_transaction = Transaction.free_transaction free_transaction = Transaction.free_transaction
jar_cmp = Transaction.jar_cmp jar_cmp = Transaction.jar_cmp
def commit(self, subtransaction=None): def commit(self, subtransaction=None):
"""Finalize the transaction.""" """Finalize the transaction."""
objects = self._objects objects = self._objects
subjars = [] subjars = []
if subtransaction: if subtransaction:
if self._sub is None: if self._sub is None:
...@@ -732,7 +732,7 @@ try: ...@@ -732,7 +732,7 @@ try:
subjars = self._sub.values() subjars = self._sub.values()
subjars.sort(jar_cmp) subjars.sort(jar_cmp)
self._sub = None self._sub = None
# If there were any non-subtransaction-aware jars # If there were any non-subtransaction-aware jars
# involved in earlier subtransaction commits, we need # involved in earlier subtransaction commits, we need
# to add them to the list of jars to commit. # to add them to the list of jars to commit.
...@@ -830,17 +830,17 @@ try: ...@@ -830,17 +830,17 @@ try:
pass pass
else: else:
# Merge in all the jars used by one of the subtransactions. # Merge in all the jars used by one of the subtransactions.
# When the top-level subtransaction commits, the tm must # When the top-level subtransaction commits, the tm must
# call commit_sub() for each jar involved in one of the # call commit_sub() for each jar involved in one of the
# subtransactions. The commit_sub() method should call # subtransactions. The commit_sub() method should call
# tpc_begin() on the storage object. # tpc_begin() on the storage object.
# It must also call tpc_begin() on jars that were used in # It must also call tpc_begin() on jars that were used in
# a subtransaction but don't support subtransactions. # a subtransaction but don't support subtransactions.
# These operations must be performed on the jars in order. # These operations must be performed on the jars in order.
# Modify jars inplace to include the subjars, too. # Modify jars inplace to include the subjars, too.
jars += subjars jars += subjars
jars.sort(jar_cmp) jars.sort(jar_cmp)
...@@ -887,8 +887,8 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw): ...@@ -887,8 +887,8 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw):
wfs = self.getWorkflowsFor(ob) wfs = self.getWorkflowsFor(ob)
if wfs: if wfs:
for w in wfs: for w in wfs:
# LOG('ERP5WorkflowTool.wrapWorkflowMethod, is wfMSupported', 0, # LOG('ERP5WorkflowTool.wrapWorkflowMethod, is wfMSupported', 0,
# repr((w.isWorkflowMethodSupported(ob, method_id), # repr((w.isWorkflowMethodSupported(ob, method_id),
# w.getId(), ob, method_id ))) # w.getId(), ob, method_id )))
if (hasattr(w, 'isWorkflowMethodSupported') if (hasattr(w, 'isWorkflowMethodSupported')
and w.isWorkflowMethodSupported(ob, method_id)): and w.isWorkflowMethodSupported(ob, method_id)):
...@@ -897,7 +897,7 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw): ...@@ -897,7 +897,7 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw):
wf_list.append(w) wf_list.append(w)
else: else:
wfs = () wfs = ()
# If no transition matched, simply call the method # If no transition matched, simply call the method
# And return # And return
if len(wf_list)==0: if len(wf_list)==0:
return apply(func, args, kw) return apply(func, args, kw)
...@@ -1977,3 +1977,27 @@ try: ...@@ -1977,3 +1977,27 @@ try:
AttrDict.has_key = AttrDict_has_key AttrDict.has_key = AttrDict_has_key
except ImportError: except ImportError:
pass pass
############################################################################
#CookieCrumbler: remove "?came_from" from getLoginUrl (called by request.unauthorized)
from Products.CMFCore.CookieCrumbler import CookieCrumbler
class PatchedCookieCrumbler(CookieCrumbler):
def getLoginURL(self):
'''
Redirects to the login page.
'''
if self.auto_login_page:
req = self.REQUEST
resp = req['RESPONSE']
iself = getattr(self, 'aq_inner', self)
parent = getattr(iself, 'aq_parent', None)
page = getattr(parent, self.auto_login_page, None)
if page is not None:
retry = getattr(resp, '_auth', 0) and '1' or ''
url = '%s?retry=%s&disable_cookie_login__=1' % (
page.absolute_url(), retry)
return url
return None
CookieCrumbler.getLoginURL=PatchedCookieCrumbler.getLoginURL
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment