<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_permission(self, permission, value, parent=False, admin=False):
 """ Sets permission for personal information. Returns False silently if unable to set permission. Returns True if successful. """

        try:
            if not getattr(self, 'parent_{}'.format(permission)) and not parent and not admin:
                return False
            level = 'parent' if parent else 'self'
            setattr(self, '{}_{}'.format(level, permission), value)

            # Set student permission to false if parent sets permission to false.
            if parent and not value:
                setattr(self, 'self_{}'.format(permission), False)

            self.save()
            return True
        except Exception as e:
            logger.error("Error occurred setting permission {} to {}: {}".format(permission, value, e))
            return False