<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def envelope(self, data, many):
 """Wrap result in envelope."""

        if not many:
            return data

        result = dict(
            hits=dict(
                hits=data,
                total=self.context.get('total', len(data))
            )
        )

        page = self.context.get('page')
        if page:
            links_pagination_factory = self.context.get(
                'links_pagination_factory',
                default_links_pagination_factory
            )

            urlkwargs = self.context.get('urlkwargs', {})

            result['links'] = links_pagination_factory(page, urlkwargs)

        return result