<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create(self, cls, record, user='undefined'):
 """Persist new record 'jane' Traceback (most recent call last):
 ValueError: Unsupported record type "badcls" Traceback (most recent call last):
 KeyError: 'There is already a record for tstoretest/1' Traceback (most recent call last):
 ValueError: Undefined field Traceback (most recent call last):
 ValueError: Bad record (INVALID_TEXT_REPRESENTATION) """

        self.validate_record(cls, record)
        record[CREATION_DATE] = record[UPDATE_DATE] = self.nowstr()
        record[CREATOR] = record[UPDATER] = user
        try:
            return self.db.insert(cls, record)
        except (psycopg2.IntegrityError, psycopg2.ProgrammingError,
                psycopg2.DataError) as error:
            logging.warning("{} {}: {}".format(
                error.__class__.__name__,
                psycopg2.errorcodes.lookup(error.pgcode), error.pgerror))
            if error.pgcode == psycopg2.errorcodes.UNIQUE_VIOLATION:
                raise KeyError('There is already a record for {}/{}'.format(
                    cls, record[ID]))
            elif error.pgcode == psycopg2.errorcodes.UNDEFINED_COLUMN:
                raise ValueError('Undefined field')
            else:
                raise ValueError('Bad record ({})'.format(
                    psycopg2.errorcodes.lookup(error.pgcode)))