From: optilude <svn...@pl...> - 2006-08-29 00:23:53
|
Author: optilude Date: Tue Aug 29 00:23:48 2006 New Revision: 10693 Modified: plone.portlets/trunk/plone/portlets/registration.py plone.portlets/trunk/plone/portlets/storage.py Log: Be a bit more safe Modified: plone.portlets/trunk/plone/portlets/registration.py ============================================================================== --- plone.portlets/trunk/plone/portlets/registration.py (original) +++ plone.portlets/trunk/plone/portlets/registration.py Tue Aug 29 00:23:48 2006 @@ -1,3 +1,4 @@ +from zope.interface import implements from persistent import Persistent from plone.portlets.interfaces import IPortletType @@ -7,6 +8,7 @@ This is persistent so that it can be stored as a local utility. """ + implements(IPortletType) title = u'' description = u'' Modified: plone.portlets/trunk/plone/portlets/storage.py ============================================================================== --- plone.portlets/trunk/plone/portlets/storage.py (original) +++ plone.portlets/trunk/plone/portlets/storage.py Tue Aug 29 00:23:48 2006 @@ -42,7 +42,7 @@ return range(len(self._assignments)) def __iter__(self): - return iter(self._assignments) + return iter(self.keys()) def __getitem__(self, key): return self._assignments[self._key(key)] @@ -68,7 +68,10 @@ return items def __contains__(self, key): - key = self._key(key) + try: + key = self._key(key) + except KeyError: + return False return bool(key >= 0 and key < len(self._assignments)) has_key = __contains__ @@ -85,11 +88,10 @@ def saveAssignment(self, assignment): key = getattr(assignment, '__name__', None) - if key: - try: - key = self._key(key) - except KeyError: - key = None + try: + key = self._key(key) + except KeyError: + key = None if key is not None: self._assignments[key] = assignment else: @@ -124,7 +126,7 @@ """ try: key = int(key) - except ValueError: + except (ValueError, TypeError,): raise KeyError, key if key < 0 or key >= len(self._assignments): raise KeyError, key |