I want to generate a choicelist for all specs that inherit from imagekit.specs.ImageSpec
.
The idea is to allow users of the admin interface to select an ImageSpec to add to a picture.
i.e:
class Display(ImageSpec):
pre_cache = True
increment_count = True
processors = [ResizeDisplay,]
class SingleDisplay(ImageSpec):
pre_cache = True
increment_count = True
processors = [SingleDisplayResize]
class Reflection(ImageSpec):
increment_count = True
processors = [ResizeDisplay, ReflectionProcessor]
class SingleDisplayReflection(ImageSpec):
increment_count = True
processors = [SingleDisplayResize, ReflectionProcessor]
results in a drop-down list "Display, Singledisplay, Reflection, Singledisplayreflection"
Well, something like the following will get you a list of all the ImageSpec subclasses defined in the file:
You could then generate the choices list from the
__name__
attribute of each class in thesubclasses
list.