Пример #1
0
 def __delitem__(self, key):
     # make sure our lazy property gets set
     l = self.__len
     item = self.__data[key]
     del self.__data[key]
     l.change(-1)
     uncontained(item, self, key)
Пример #2
0
 def test_uncontained_no_attr_fixing_up(self):
     # Causes the attribute error to be ignored
     import zope.container.contained
     zope.container.contained.fixing_up = True
     try:
         uncontained(self, 42)
     finally:
         zope.container.contained.fixing_up = False
Пример #3
0
    def __delitem__(self, name):
        obj = self[name]
        self.__delSublocations(obj)

        uncontained(self._data[name], self, name)
        del self._data[name]

        if name in self._order:
            self._order.remove(name)
        if name in self._container_order:
            self._container_order.remove(name)
Пример #4
0
 def __delitem__(self, key):
     value = self[key]
     # First remove the parent and name from the object.
     if self._m_mapping_key is not None:
         try:
             delattr(value, self._m_mapping_key)
         except AttributeError:
             # Sometimes we do not control those attributes.
             pass
     if self._m_parent_key is not None:
         try:
             delattr(value, self._m_parent_key)
         except AttributeError:
             # Sometimes we do not control those attributes.
             pass
     # Let's now remove the object from the database.
     if self._m_remove_documents:
         self._m_jar.remove(value)
     # Send the uncontained event.
     contained.uncontained(value, self, key)
Пример #5
0
    def __delitem__(self, key):
        """ See `IOrderedContainer`.

        >>> oc = OrderedContainer()
        >>> oc.keys()
        []
        >>> oc['foo'] = 'bar'
        >>> oc['baz'] = 'quux'
        >>> oc['zork'] = 'grue'
        >>> oc.items()
        [('foo', 'bar'), ('baz', 'quux'), ('zork', 'grue')]
        >>> int(len(oc._order) == len(oc._data))
        1
        >>> del oc['baz']
        >>> oc.items()
        [('foo', 'bar'), ('zork', 'grue')]
        >>> int(len(oc._order) == len(oc._data))
        1
        """

        uncontained(self._data[key], self, key)
        del self._data[key]
        self._order.remove(key)
Пример #6
0
 def __delitem__(self, name):
     """Delete the named object from the folder. Raises a KeyError
        if the object is not found."""
     uncontained(self.data[name], self, name)
     del self.data[name]
Пример #7
0
 def test_uncontained_no_attr(self):
     with self.assertRaises(AttributeError):
         uncontained(self, 42)
Пример #8
0
 def __delitem__(self, key):
     uncontained(self._data[key], self, key)
     del self._data[key]
     self._order.remove(key)
Пример #9
0
 def __delitem__(self, key):
     '''See interface `IWriteContainer`'''
     uncontained(self.__data[key], self, key)
     del self.__data[key]
Пример #10
0
 def __delitem__(self, key):
     # make sure our lazy property gets set
     l = self.__len
     uncontained(self._SampleContainer__data[key], self, key)
     del self._SampleContainer__data[key]
     l.change(-1)