<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def compile_obj(self, obj):
 """ generate a context based on the given obj :param obj: an instance of the model """

        res = {}
        for column in self.columns:
            if isinstance(column['__col__'], ColumnProperty):
                value = self._get_column_value(obj, column)

            elif isinstance(column['__col__'], RelationshipProperty):
                value = self._get_relationship_value(obj, column)

            res[column['name']] = value

        return res