Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when calculating etag value on non-tabbedview. #67

Merged
merged 1 commit into from Mar 13, 2017

Conversation

jone
Copy link
Member

@jone jone commented Mar 10, 2017

The ETagValue adapter must always return a string.

@Rotonen You have noticed None beeing returned as etag value, but I believe that this is not possible because of the only return statement:

return IDictStorage(self.published).get(storage_key) or ''

Whenever it would be None, it would return an empty string.

But I have found an error when not accessing a tabbed view:

Error in test test_default_value_is_empty_string (ftw.tabbedview.tests.test_caching.TestETagValue)
Traceback (most recent call last):
....
  File "/Users/jone/projects/packages/ftw.tabbedview/ftw/tabbedview/tests/test_caching.py", line 28, in get_etag_value_for
    return adapter()
  File "/Users/jone/projects/packages/ftw.tabbedview/ftw/tabbedview/caching.py", line 26, in __call__
    storage_key = storage_key_generator.get_key()
AttributeError: 'NoneType' object has no attribute 'get_key'

I belive that this error may have been catched and None was returned.
This change fixes this issue.

(//cc @deiferni @lukasgraf as discussed)

The ETagValue adapter must always return a string.
@Rotonen
Copy link
Contributor

Rotonen commented Mar 10, 2017

@jone This reliably triggers for me on the first login into a freshly installed GEVER.

Traceback (most recent call last):
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.transformchain-1.0.3-py2.7.egg/plone/transformchain/transformer.py", line 48, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.caching-1.0-py2.7.egg/plone/caching/hooks.py", line 144, in transformIterable
    self.mutate()
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.caching-1.0-py2.7.egg/plone/caching/hooks.py", line 169, in mutate
    operation.modifyResponse(rule, request.response)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/default.py", line 143, in modifyResponse
    etag = getETagAnnotation(self.published, self.request, etags)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 515, in getETagAnnotation
    etag = getETag(published, request, keys=keys, extraTokens=extraTokens)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 546, in getETag
    value = component()
  File "/Users/joni/koodaus/git/opengever.core/eggs/ftw.tabbedview-3.7.0-py2.7.egg/ftw/tabbedview/caching.py", line 23, in __call__
    storage_key = storage_key_generator.get_key()
  File "/Users/joni/koodaus/git/opengever.core/eggs/ftw.tabbedview-3.7.0-py2.7.egg/ftw/tabbedview/defaulttab.py", line 30, in get_key
    return '-'.join(parts)
TypeError: sequence item 4: expected string, NoneType found

@Rotonen
Copy link
Contributor

Rotonen commented Mar 10, 2017

Something also flares up on WebDAV locks:

2017-03-10 18:58:46 ERROR root Swallowed exception in plone.caching IPubAfterTraversal event handler
Traceback (most recent call last):
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.caching-1.0-py2.7.egg/plone/caching/hooks.py", line 82, in intercept
    responseBody = operation.interceptResponse(rule, request.response)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/default.py", line 102, in interceptResponse
    etag = getETagAnnotation(self.published, self.request, keys=etags)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 515, in getETagAnnotation
    etag = getETag(published, request, keys=keys, extraTokens=extraTokens)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 546, in getETag
    value = component()
  File "/Users/joni/koodaus/git/opengever.core/eggs/ftw.tabbedview-3.7.0-py2.7.egg/ftw/tabbedview/caching.py", line 22, in __call__
    IDefaultTabStorageKeyGenerator)
  File "/Users/joni/koodaus/git/opengever.core/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 109, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((<Document at /fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5>, <Document at /fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5>, <HTTPRequest, URL=http://rotobock.local:8080/fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5/LOCK>), <InterfaceClass ftw.tabbedview.interfaces.IDefaultTabStorageKeyGenerator>, u'')
2017-03-10 18:59:29 ERROR root Swallowed exception in plone.caching IPubAfterTraversal event handler
Traceback (most recent call last):
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.caching-1.0-py2.7.egg/plone/caching/hooks.py", line 82, in intercept
    responseBody = operation.interceptResponse(rule, request.response)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/default.py", line 102, in interceptResponse
    etag = getETagAnnotation(self.published, self.request, keys=etags)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 515, in getETagAnnotation
    etag = getETag(published, request, keys=keys, extraTokens=extraTokens)
  File "/Users/joni/koodaus/git/opengever.core/eggs/plone.app.caching-1.1.6-py2.7.egg/plone/app/caching/operations/utils.py", line 546, in getETag
    value = component()
  File "/Users/joni/koodaus/git/opengever.core/eggs/ftw.tabbedview-3.7.0-py2.7.egg/ftw/tabbedview/caching.py", line 22, in __call__
    IDefaultTabStorageKeyGenerator)
  File "/Users/joni/koodaus/git/opengever.core/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 109, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((<Document at /fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5>, <Document at /fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5>, <HTTPRequest, URL=http://rotobock.local:8080/fd/ordnungssystem/ressourcen-und-support/finanzen/planung/finanzplanung/dossier-5/document-5/UNLOCK>), <InterfaceClass ftw.tabbedview.interfaces.IDefaultTabStorageKeyGenerator>, u'')

Copy link
Contributor

@deiferni deiferni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

this probably won't fix @Rotonen problem though as in his case user.getId() seems to return None.

@deiferni deiferni merged commit 891e587 into master Mar 13, 2017
@deiferni deiferni deleted the jone-etag-value-error branch March 13, 2017 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants