~georgeyk/stoqlib/ideale-henrique

« back to all changes in this revision

Viewing changes to stoqlib/lib/component.py

  • Committer: georgeyk
  • Date: 2009-08-18 12:21:57 UTC
  • mfrom: (3096.1.11 stoqlib)
  • Revision ID: georgeyk.dev@gmail.com-20090818122157-adpvo26sbvzgwswo
merged with master

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
    """Adapter base class, everything you want to adapt must subclass this.
166
166
    """
167
167
 
168
 
    def __init__(self):
169
 
        self._adapterCache = {}
170
 
 
171
168
    #
172
169
    # Class methods
173
170
    #
250
247
        if not isinstance(iface, InterfaceClass):
251
248
            raise TypeError('iface must be an Interface')
252
249
 
 
250
        if not hasattr(self, '_adapterCache'):
 
251
            self._adapterCache = {}
 
252
 
253
253
        k = qual(iface)
254
254
        if k in self._adapterCache:
255
255
            raise AdapterError('%s already has a facet for interface %s' %
326
326
    except TypeError:
327
327
        is_adaptable = False
328
328
 
329
 
    if is_adaptable:
 
329
    if is_adaptable and hasattr(obj, '_adapterCache'):
330
330
        return obj._adapterCache.get(qual(iface))
331
331
adapter_hooks.append(_adapter_hook)
332
332