Skip to content

Backport PR #10496 on branch 5.x #10544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2017
Merged

Backport PR #10496 on branch 5.x #10544

merged 1 commit into from
May 11, 2017

Conversation

lumberbot-app[bot]
Copy link
Contributor

@lumberbot-app lumberbot-app bot commented May 11, 2017

Backport PR #10496: Define _repr_mimebundle_

Allows objects to display arbitrary mime-types by returning a mimebundle. This is getting increasingly important as custom mime-types are growing in popularity.

  • mime-bundle is computed first, but other formatters are still called
  • if a mime-type is present in repr-mimebundle, _repr_<mime>_ will not be called (avoids redundant calls for backward-compatible objects)

closes 10090

cc rgbkrk

Alternative design: rather than single method returning the mimebundle itself, return mime-keyed mapping to callables, e.g.:

def _repr_mime_methods_(self):
    return {
        'text/html': self._repr_html_,
    }

Another more minor alternative: rather than allowing return of data or (data, metadata), require returning the full mime-bundle with data, metadata keys:

def _repr_mimebundle(self):
    return {
        'data': {
            'application/vnd.foo+json': [1,2,3],
        },
    }

Allows objects to display arbitrary mime-types by returning a mimebundle. This is getting increasingly important as custom mime-types are growing in popularity.

- mime-bundle is computed first, but other formatters are still called
- if a mime-type is present in repr-mimebundle, `_repr_<mime>_` will not be called (avoids redundant calls for backward-compatible objects)

closes  10090

cc  rgbkrk

Alternative design: rather than single method returning the mimebundle itself, return mime-keyed mapping to callables, e.g.:

```python
def _repr_mime_methods_(self):
    return {
        'text/html': self._repr_html_,
    }
```

Another more minor alternative: rather than allowing return of `data` or `(data, metadata)`, require returning the full mime-bundle with `data`, `metadata` keys:

```python
def _repr_mimebundle(self):
    return {
        'data': {
            'application/vnd.foo+json': [1,2,3],
        },
    }
```
@lumberbot-app lumberbot-app bot added this to the 5.4 milestone May 11, 2017
@Carreau Carreau merged commit bdc14f0 into 5.x May 11, 2017
@Carreau Carreau deleted the auto-backport-of-pr-10496 branch May 11, 2017 21:22
@Carreau Carreau added the backported PR that have been backported by MrMeeseeks label May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PR that have been backported by MrMeeseeks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant