Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
WeakKeyDictionary Class Reference
Inheritance diagram for WeakKeyDictionary:
UserDict

Public Member Functions

def __init__
 
def __delitem__
 
def __getitem__
 
def __repr__
 
def __setitem__
 
def copy
 
def get
 
def has_key
 
def items
 
def iteritems
 
def iterkeys
 
def itervalues
 
def keys
 
def popitem
 
def setdefault
 
def update
 
- Public Member Functions inherited from UserDict
def __init__
 
def __repr__
 
def __cmp__
 
def __len__
 
def __getitem__
 
def __setitem__
 
def __delitem__
 
def clear
 
def copy
 
def keys
 
def items
 
def iteritems
 
def iterkeys
 
def itervalues
 
def values
 
def has_key
 
def update
 
def get
 
def setdefault
 
def popitem
 
def __contains__
 

Data Fields

 data
 
- Data Fields inherited from UserDict
 data
 

Detailed Description

Mapping class that references keys weakly.

Entries in the dictionary will be discarded when there is no
longer a strong reference to the key. This can be used to
associate additional data with an object owned by other parts of
an application without adding attributes to those objects. This
can be especially useful with objects that override attribute
accesses.

Definition at line 134 of file weakref.py.

Constructor & Destructor Documentation

def __init__ (   self,
  dict = None 
)

Definition at line 145 of file weakref.py.

146  def __init__(self, dict=None):
147  self.data = {}
148  if dict is not None: self.update(dict)
149  def remove(k, selfref=ref(self)):
150  self = selfref()
151  if self is not None:
152  del self.data[k]
153  self._remove = remove

Member Function Documentation

def __delitem__ (   self,
  key 
)

Definition at line 154 of file weakref.py.

References UserDict.data, _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, Request.data, simple_producer.data, _Environ.data, FormContentDict.data, and xmllib.ref.

155  def __delitem__(self, key):
156  for ref in self.data.iterkeys():
157  o = ref()
158  if o == key:
159  del self.data[ref]
160  return
def __getitem__ (   self,
  key 
)

Definition at line 161 of file weakref.py.

References UserDict.data, _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, Request.data, simple_producer.data, _Environ.data, FormContentDict.data, and xmllib.ref.

162  def __getitem__(self, key):
163  return self.data[ref(key)]
def __repr__ (   self)

Definition at line 164 of file weakref.py.

165  def __repr__(self):
166  return "<WeakKeyDictionary at %s>" % id(self)
def __setitem__ (   self,
  key,
  value 
)

Definition at line 167 of file weakref.py.

References WeakKeyDictionary._remove, UserDict.data, _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, Request.data, simple_producer.data, _Environ.data, FormContentDict.data, and xmllib.ref.

168  def __setitem__(self, key, value):
169  self.data[ref(key, self._remove)] = value
def copy (   self)

Definition at line 170 of file weakref.py.

171  def copy(self):
172  new = WeakKeyDictionary()
173  for key, value in self.data.items():
174  o = key()
175  if o is not None:
176  new[o] = value
177  return new
def get (   self,
  key,
  default = None 
)

Definition at line 178 of file weakref.py.

References xmllib.ref.

179  def get(self, key, default=None):
180  return self.data.get(ref(key),default)
def has_key (   self,
  key 
)

Definition at line 181 of file weakref.py.

References xmllib.ref.

182  def has_key(self, key):
183  try:
184  wr = ref(key)
185  except TypeError:
186  return 0
187  return self.data.has_key(wr)
def items (   self)

Definition at line 188 of file weakref.py.

189  def items(self):
190  L = []
191  for key, value in self.data.items():
192  o = key()
193  if o is not None:
194  L.append((o, value))
195  return L
def iteritems (   self)

Definition at line 196 of file weakref.py.

197  def iteritems(self):
198  return WeakKeyedItemIterator(self)
def iterkeys (   self)

Definition at line 199 of file weakref.py.

200  def iterkeys(self):
return WeakKeyedKeyIterator(self)
def itervalues (   self)

Definition at line 203 of file weakref.py.

204  def itervalues(self):
205  return self.data.itervalues()
def keys (   self)

Definition at line 206 of file weakref.py.

207  def keys(self):
208  L = []
209  for wr in self.data.keys():
210  o = wr()
211  if o is not None:
212  L.append(o)
213  return L
def popitem (   self)

Definition at line 214 of file weakref.py.

215  def popitem(self):
216  while 1:
217  key, value = self.data.popitem()
218  o = key()
219  if o is not None:
220  return o, value
def setdefault (   self,
  key,
  default 
)

Definition at line 221 of file weakref.py.

References WeakKeyDictionary._remove, and xmllib.ref.

222  def setdefault(self, key, default):
223  return self.data.setdefault(ref(key, self._remove),default)
def update (   self,
  dict 
)

Definition at line 224 of file weakref.py.

References WeakKeyDictionary._remove, UserDict.data, _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, Request.data, simple_producer.data, _Environ.data, FormContentDict.data, and xmllib.ref.

225  def update(self, dict):
226  d = self.data
227  for key, value in dict.items():
228  d[ref(key, self._remove)] = value
229 

Field Documentation

data

Definition at line 146 of file weakref.py.


The documentation for this class was generated from the following file: