<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def permitted_actions(self, user, obj=None):
 """Determine list of permitted actions for an object or object pattern. :param user: The user to test. :type user: ``User`` :param obj: A function mapping from action names to object paths to test. :type obj: callable :returns: ``list(tutelary.engine.Action)`` -- permitted actions. """

        try:
            if not self._obj_ok(obj):
                raise InvalidPermissionObjectException
            return user.permset_tree.permitted_actions(obj)
        except ObjectDoesNotExist:
            return []