Advertisement
Guest User

FileHandler

a guest
Apr 20th, 2010
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. class ParadigmFileHandler(FileHandler):
  2.  
  3.     path        = cns.PAR_PATH
  4.     wildcard    = cns.PAR_WILDCARD
  5.     name        = 'paradigm'
  6.    
  7.     def init(self, info):
  8.         #self.install_menu(info)
  9.         pass
  10.        
  11.     def install_menu(self, info):
  12.         print 'installing'
  13.         actions = [Action(name='Load paradigm', action='load_file'),
  14.                    Action(name='Save paradigm', action='save_file'),
  15.                    Action(name='Save as paradigm', action='saveas_file'),
  16.                    #Action(name='New paradigm',  action='create_paradigm'),
  17.                    ]
  18.         info.ui.view.menubar = MenuBar(Menu(*actions, name='File'))
  19.         #info.ui.modified = True
  20.         info.ui.updated = True
  21.    
  22.     def load_object(self, file, info):
  23.         with open(file, 'rb') as fh:
  24.             info.object.paradigm = pickle.load(fh)
  25.            
  26.     def save_object(self, file, info):
  27.         with open(file, 'wb') as fh:
  28.             pickle.dump(info.object.paradigm, fh, -1)
  29.            
  30.     def object_modified(self, info):
  31.         return info.object.paradigm._modified
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement