Skip to content
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

Document apptools.type_registry #134

Open
corranwebster opened this issue Sep 27, 2020 · 1 comment
Open

Document apptools.type_registry #134

corranwebster opened this issue Sep 27, 2020 · 1 comment
Labels
component: documentation Issues related to the Sphinx documentation

Comments

@corranwebster
Copy link
Contributor

This is a comparatively recent addition to apptools. It should be documented with examples of the problems it is idesigned to solve.

@rkern
Copy link
Member

rkern commented Sep 29, 2020

There are a number of places where you want to specify some kind of object for a given type (gracefully handling subtypes, lazy registration, etc.). For example, in IPython, I want to register a pretty-printer function for numpy arrays. Or in Traits UI, I might want to make an InstanceEditor implementation that looks up a Controller/ModelView from one of these registries to wrap around a model object. I use (a vendorized version of) this code in qt_binder to map Qt widget types to Binder classes.

It is similar to functools.singledispatch and our adaptation subsystem except that the mapped object is entirely general, not just a function that will be called on the object or an adapter wrapped around it. It's a light-weight implementation of the concept, and the registry object can be explicitly managed (i.e. no hidden global state unless if you decide to hide it somewhere).

@rahulporuri rahulporuri added the component: documentation Issues related to the Sphinx documentation label Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: documentation Issues related to the Sphinx documentation
Projects
None yet
Development

No branches or pull requests

3 participants