def database_command(self, menuitem, name): if name == 'connect': if self.conn is None and not self.dialogs['dbname']: msg = 'connect to which database?' dbname = self.dblist.get_selected_data()[0].datname self.dialogs['dbname'] = dialogs.Entry(msg, name='dbname') entry = self.dialogs['dbname'] entry.set_ok(self.ok_dialog) entry.set_cancel(self.destroy_dialog) entry.set(dbname) else: dialogs.Message('no multiple connections yet') elif name == 'disconnect': if self.conn is not None: self.main.close() self.conn.close() self.conn = None self.dbname = None else: dialogs.Message('no connection to leave') elif name in ['backup', 'restore']: filesel = FileSelection(title='%s database' % name) filesel.cancel_button.connect('clicked', lambda x: filesel.destroy()) filesel.show() bkup_path = self.cfg['import_path'] filesel.set_filename(self._filepath_(bkup_path)) filesel.ok_button.connect('clicked', self.ok_file, filesel) filesel.set_data('action', name) else: dialogs.Message('%s unimplemented' % name)
def ask_dialog(self, button, data): if not self.dialogs[data]: if data == 'create': self.dialogs[data] = dialogs.Entry('create trait', name='create') self.dialogs[data].set_ok(self.create_trait) self.dialogs[data].set_cancel(self.destroy_dialog)
def trait_command(self, menuitem, action): traits = self._get_listbox('traits', 'trait') if action == 'drop': clause = In('trait', traits) & Eq('profile', self.current.profile) self.profiletrait.cmd.delete(clause=clause) self.__set_pages(self.current.profile) elif action == 'order': if not self.dialogs['order']: self.dialogs['order'] = dialogs.Entry('enter order', name='order') self.dialogs['order'].set_ok(self.set_order) self.dialogs['order'].set_cancel(self.destroy_dialog)
def ask_dialog(self, button, data): if not self.dialogs[data]: if data == 'create': self.dialogs[data] = dialogs.Entry('create profile', name='create') self.dialogs[data].set_ok(self.create_profile) elif data == 'copy': self.dialogs[data] = dialogs.CList('copy profile', name='copy') dialog = self.dialogs[data] dialog.set_rows( self.profiles.select(fields='profile', order='profile')) dialog.set_ok(self.src_profile_selected) elif data == 'export': pdb = PaellaDatabase(self.conn) profiles = pdb.profiles self.dialogs[data].set_cancel(self.destroy_dialog)
def pkey_command(self, menuitem, command): if command == 'insert': if self.dialogs['insert'] is None: dialog = dialogs.Entry('insert a %s' % self.pkey, name='insert') dialog.set_ok(self.pkey_insert_ok) dialog.set_cancel(self.destroy_dialog) self.dialogs['insert'] = dialog elif command == 'update': dialogs.Message('need to set update to cascade in db') elif command == 'done': value = None try: value = self.listbox.get_selected_data()[0][0] except IndexError: dialogs.Message('need to select %s first' % self.pkey) if value is not None: dialogs.Message('ok, i am done.')