home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / peak / events / sa_support.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  1.8 KB  |  49 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from sqlalchemy.orm.attributes import get_attribute, set_attribute, ClassManager
  5. from trellis import Cells, NO_VALUE, CellFactories, Cell, Performer
  6. from new import instancemethod
  7.  
  8. class SAInstrument(ClassManager):
  9.     
  10.     def install_descriptor(self, key, inst):
  11.         if key not in CellFactories(self.class_):
  12.             setattr(self.class_, key, inst)
  13.         
  14.  
  15.     
  16.     def uninstall_descriptor(self, key):
  17.         if key not in CellFactories(self.class_):
  18.             delattr(self.class_, key)
  19.         
  20.  
  21.     
  22.     def install_state(self, instance, state):
  23.         cells = Cells(instance)
  24.         if not cells:
  25.             cls = instance.__class__
  26.             factories = CellFactories(cls)
  27.             getter = instancemethod(get_attribute, instance)
  28.             attrs = []
  29.             for attr in self:
  30.                 if attr not in factories:
  31.                     continue
  32.                 
  33.                 attrs.append(attr)
  34.                 cells[attr] = Cell(instancemethod(getter, attr), factories[attr].im_self.initial_value(instance))
  35.             
  36.             
  37.             def setter():
  38.                 for attr in attrs:
  39.                     if cells[attr].was_set:
  40.                         set_attribute(instance, attr, cells[attr].value)
  41.                         continue
  42.                 
  43.  
  44.             instance._observer = Performer(setter)
  45.         
  46.         super(SAInstrument, self).install_state(instance, state)
  47.  
  48.  
  49.