Skip to content

Instantly share code, notes, and snippets.

@zakdances
Created March 12, 2013 16:26
Show Gist options
  • Save zakdances/d4a8890b2b0eafe1fc84 to your computer and use it in GitHub Desktop.
Save zakdances/d4a8890b2b0eafe1fc84 to your computer and use it in GitHub Desktop.
Beaker error: copy.deepcopy( session ) produces "AttributeError: 'Morsel' object has no attribute 'encode'"
Traceback (most recent call last):
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.4-py2.7.egg/pyramid_debugtoolbar/panels/performance.py", line 55, in resource_timer_handler
result = handler(request)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/router.py", line 161, in handle_request
response = view_callable(context, request)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/config/views.py", line 235, in _secured_view
result = _permitted(context, request)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/config/views.py", line 231, in _permitted
principals = self.authn_policy.effective_principals(request)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/authentication.py", line 155, in effective_principals
groups = self.callback(userid, request)
File "/Users/me/MyProject/myproject/lib/security.py", line 38, in groupfinder
if request.user:
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/pyramid/util.py", line 50, in <lambda>
fn = lambda this: callable(this)
File "/Users/me/MyProject/myproject/lib/security.py", line 60, in returnUser
myDoc = copy.deepcopy(session) if session and session.get('GUID') == u_id else None
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
state = deepcopy(state, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
y = copier(x, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
state = deepcopy(state, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
y = copier(x, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 358, in _reconstruct
y[key] = value
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 591, in __setitem__
rval, cval = self.value_encode(value)
File "/Users/me/.virtualenvs/myproject/lib/python2.7/site-packages/beaker/session.py", line 70, in value_encode
sig = HMAC.new(self.secret, val.encode('UTF-8'), SHA1).hexdigest()
AttributeError: 'Morsel' object has no attribute 'encode'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment