Skip to content

Commit

Permalink
Failover if registry can't be found. Mainly for tests, because I don'…
Browse files Browse the repository at this point in the history
…t want to figure out how to add a mock registry in a docstring doctest. Grr.
  • Loading branch information
esteele committed Sep 20, 2015
1 parent dd443d0 commit 3c9b7ac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plone/app/vocabularies/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.ZCTextIndex.ParseTree import ParseError
from zope.browser.interfaces import ITerms
from zope.component import getUtility
from zope.component import queryUtility
from zope.formlib.interfaces import ISourceQueryView
from zope.interface import implementer
from zope.interface import provider
Expand Down Expand Up @@ -151,8 +151,12 @@ def __init__(self, context, base_query={}, default_query=None):
self.catalog = getToolByName(context, "portal_catalog")
self.portal_tool = getToolByName(context, "portal_url")
self.portal_path = self.portal_tool.getPortalPath()
registry = getUtility(IRegistry)
self.encoding = registry.get('plone.default_charset', 'ascii')

registry = queryUtility(IRegistry)
if registry is not None:
self.encoding = registry.get('plone.default_charset', 'ascii')
else:
self.encoding = 'ascii'

def __contains__(self, value):
"""Return whether the value is available in this source
Expand Down

0 comments on commit 3c9b7ac

Please sign in to comment.