Re: [TurboGears] #2475: Activate session_filter makes the quickstarted test_controllers tests fails

7 views
Skip to first unread message

TurboGears

unread,
Mar 10, 2010, 3:51:23 AM3/10/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.1.1
Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by cdevienne):

Another way to fix the problem, still in cherrypy/_cphttptools.py. Replace
:

{{{
#!python
431 cookie = self.simple_cookie.output()
}}}

with :

{{{
#!python
431 cookie = self.simple_cookie.output(sep='\n')
}}}

--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:4>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

TurboGears

unread,
Mar 9, 2010, 12:39:18 PM3/9/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: __unclassified__

Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by cdevienne):

Same one with correct formatting.

{{{
#!python

432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.split(": ", 1)
435 self.header_list.append((name, value))
}}}

with :

{{{
#!python

432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.strip('\r').split(": ", 1)
435 self.header_list.append((name, value))

}}}

--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:2>

TurboGears

unread,
Mar 9, 2010, 12:12:32 PM3/9/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: __unclassified__
Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Keywords:
------------------------+---------------------------------------------------
On a quickstarted TG 1.1 project with identity:
* adding session_filter.on = True in app.cfg
* run the test_controllers.py tests

-> AssertionError: Bad header value:
'session_id=bb5e49bea3dd167a819cc3463d7b8182f2734d99; expires=Tue, 09 Mar
2010 18:06:48 GMT; Path=/\r' (bad char: '\r')

The problems occurs when multiple cookies (in that case : session_id an
tg-visit) are in the response : a "\r" seems to be added between the two
cookies.

I could not find a workaround.

It may be related to #2446.

--
Ticket URL: <http://trac.turbogears.org/ticket/2475>

TurboGears

unread,
Mar 9, 2010, 6:17:53 PM3/9/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.1.1
Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Changes (by chrisz):

* milestone: __unclassified__ => 1.1.1

--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:3>

TurboGears

unread,
Mar 9, 2010, 12:34:58 PM3/9/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: __unclassified__
Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by cdevienne):

Sorry for answering myself, but I found a way to fix the problem, by
patching cherrypy...

in cherrypy/_cphttptools.py, around at line 434 :

432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.split(": ", 1)
435 self.header_list.append((name, value))

with :

432 if cookie:


433 for line in cookie.split("\n"):
434 name, value = line.strip('\r').split(": ", 1)
435 self.header_list.append((name, value))

solved the issue.

Now I am not sure it is ideal, nor if we could make this go into a bugfix
release of CherryPy.

--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:1>

TurboGears

unread,
Mar 10, 2010, 4:21:13 AM3/10/10
to turbogear...@googlegroups.com
#2475: Activate session_filter makes the quickstarted test_controllers tests fails
------------------------+---------------------------------------------------
Reporter: cdevienne | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.1.1
Component: TurboGears | Version: 1.1 HEAD
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by cdevienne):

The original problem probably comes from the !BaseCookie.output function
which changed its default separator in python 2.5 :

http://docs.python.org/library/cookie.html#Cookie.BaseCookie.output

I guess we should do a bug report to !CherryPy since it can be considered
as a python 2.5 regression, but can we really expect a bugfix release ?

In addition, here is a dirty monkey path that workaround this issue by
reverting !SimpleCookie.output to the python<2.5 behavior :

{{{
#!python
import Cookie

def output(self, attrs=None, header='Set-Cookie:', sep='\n'):
return self._orig_output(attrs, header, sep)

Cookie.SimpleCookie._orig_output = Cookie.SimpleCookie.output
Cookie.SimpleCookie.output = output

}}}

--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:5>

Reply all
Reply to author
Forward
0 new messages