Beispiel #1
0
 def update (self, entry):
     (day, month, year) = (None, None, None)
     
     text = string.strip (self.day.get_chars (0, -1)).encode ('latin-1')
     if text != '':
         try: day = int (text)
         except ValueError:
             Compat.error_dialog_parented (_("Invalid day field in date"),
                                             self.day.get_toplevel ())
             return -1
     
     text = string.strip (self.month.get_chars (0, -1)).encode ('latin-1')
     if text != '':
         try: month = int (text)
         except ValueError, err:
             Compat.error_dialog_parented (_("Invalid month field in date"),
                                             self.day.get_toplevel ())
             return -1
Beispiel #2
0
 def update(self, database, entry):
     '''Updates and returns the new entry.'''
     new  = None
     text = self.buff.get_text(
         self.buff.get_start_iter(),
         self.buff.get_end_iter())
     try:
         text = text.encode('latin-1')
     except UnicodeError:
         Compat.error_dialog_parented(
             _("Your text contains non Latin-1 symbols"),
             self.w.get_toplevel())
         return None
     try:
         new = self.database.create_native(text)
     except Exceptions.ParserError, msg:
         Utils.error_dialog(
             _("Error in native string parsing"), str(msg))
         return None
Beispiel #3
0
    def update (self, database, entry):
        modified = False
        
        key = string.strip (self.key.get_text ())
        if key == '':
            self.entry.key = None
            modified = True
        else:
            if not key_re.match (key):
                Compat.error_dialog_parented (
                    _("Invalid key format"), self.w.get_toplevel ())
                return None

            key = Key.Key (database, key)

            if key != self.entry.key:
                if database.has_key (key):
                     Compat.error_dialog_parented (
                         _("Key `%s' already exists") % str (key.key),
                         self.w.get_toplevel ())
                     return None
                
                self.entry.key = key
                modified = True
                
        modified = self.type != self.entry.type or modified
        
        for item in self.content:
            try:
                result = item.update(self.entry)
                
            except UnicodeError:
                f = Types.get_field(item.field)
                
                Compat.error_dialog_parented(
                    _("The `%s' field contains a non Latin-1 symbol") %
                    f.name, self.w.get_toplevel())
                return None
            
            if result == -1: return None
            
            modified = result or modified

        modified |= self.lt_update()

        if not modified:
            fields = self.entry.keys()
            fields.sort()

            if fields != self.fields: modified = 1
        
        if modified:
            return self.entry
        
        return entry