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

allow brains in vocabularies (used for related Items) #29

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGES.txt
Expand Up @@ -4,6 +4,9 @@ Changelog
1.9.5 (unreleased)
------------------

- Allow brains (used for related items in an in-and-out-widget)
[pbauer]

- Various vocabulary fixes, mostly for translations and
IntDisplayLists.
[maurits]
Expand All @@ -12,7 +15,7 @@ Changelog
1.9.4 (2013-08-29)
------------------

- Fixed error of validate_content_types when checking a field that was an
- Fixed error of validate_content_types when checking a field that was an
instance of OFS.Image.File
[ichim-david]

Expand All @@ -23,7 +26,7 @@ Changelog
1.9.3 (2013-08-14)
------------------

- Avoid UnicodeDecodeError in @@at_utils.translate if the value contains
- Avoid UnicodeDecodeError in @@at_utils.translate if the value contains
special chars
[gbastien]

Expand Down
22 changes: 13 additions & 9 deletions Products/Archetypes/utils.py
Expand Up @@ -8,14 +8,14 @@

import transaction
from zope.component import getUtility
from zope.i18n import translate
from zope.i18nmessageid import Message

from AccessControl import ClassSecurityInfo
from AccessControl import ModuleSecurityInfo
from AccessControl.SecurityInfo import ACCESS_PUBLIC

from Acquisition import aq_base, aq_inner, aq_parent
from Acquisition import ImplicitAcquisitionWrapper
from ExtensionClass import ExtensionClass
from App.class_init import InitializeClass
from Products.CMFCore.utils import getToolByName
Expand Down Expand Up @@ -357,7 +357,8 @@ def add(self, key, value, msgid=None):
def getKey(self, value, default=None):
"""get key"""
v = self._values.get(value, None)
if v: return v[1]
if v:
return v[1]
for k, v in self._values.items():
if repr(value) == repr(k):
return v[1]
Expand All @@ -369,7 +370,8 @@ def getValue(self, key, default=None):
raise TypeError('DisplayList keys must be strings, got %s' %
type(key))
v = self._keys.get(key, None)
if v: return v[1]
if v:
return v[1]
for k, v in self._keys.items():
if repr(key) == repr(k):
return v[1]
Expand Down Expand Up @@ -416,7 +418,7 @@ def _cmp(a, b):

def __cmp__(self, dest):
if not isinstance(dest, DisplayList):
raise TypeError, 'Cannot compare DisplayList to %s' % (type(dest))
raise TypeError('Cannot compare DisplayList to %s' % (type(dest)))

return cmp(self.sortedByKey()[:], dest.sortedByKey()[:])

Expand Down Expand Up @@ -532,7 +534,8 @@ def getValue(self, key, default=None):
else:
raise TypeError("Key must be string or int")
v = self._keys.get(key, None)
if v: return v[1]
if v:
return v[1]
for k, v in self._keys.items():
if repr(key) == repr(k):
return v[1]
Expand Down Expand Up @@ -560,8 +563,9 @@ def getValue(self, key, default=None):
"""
Get i18n value
"""
if not isinstance(key, basestring) and not isinstance(key, int):
raise TypeError('DisplayList keys must be strings or ints, got %s' %
if (not isinstance(key, basestring) and not isinstance(key, int) and not
isinstance(key, ImplicitAcquisitionWrapper)):
raise TypeError('DisplayList keys must be strings, ints or brains, got %s' %
type(key))
v = self._keys.get(key, None)
value = default
Expand Down Expand Up @@ -659,7 +663,7 @@ def setdefault(self, key, failobj=None):

def popitem(self):
if not self.data:
raise KeyError, 'dictionary is empty'
raise KeyError('dictionary is empty')
k = self._keys.pop()
v = self.data.get(k)
del self.data[k]
Expand Down Expand Up @@ -756,7 +760,7 @@ def wrap_method(klass, name, method, pattern='__at_wrapped_%s__'):
def unwrap_method(klass, name):
old_method = getattr(klass, name)
if not isWrapperMethod(old_method):
raise ValueError, ('Non-wrapped method %s.%s' % (klass.__name__, name))
raise ValueError('Non-wrapped method %s.%s' % (klass.__name__, name))
orig_name = getattr(old_method, ORIG_NAME)
new_method = getattr(klass, orig_name)
delattr(klass, orig_name)
Expand Down