- def url_for_material(self, slug, fmt=None):
- if fmt is None:
- fmt = self.DEFAULT_MATERIAL_FORMAT
- # No briliant idea for an API here.
- if fmt:
- return "%s.%s" % (slug, fmt)
- return slug
+ def materials(self, slug):
+ """Returns a list of pairs: (ext, iofile)."""
+ order = dict(reversed(k) for k in enumerate(self.PRIMARY_MATERIAL_FORMATS))
+ mats = self.materials_by_slug.get(slug, {}).items()
+ if not mats:
+ pass # print "!! Material missing: '%s'" % slug
+ return sorted(mats, key=lambda (x, y): order.get(x, x))
+
+ def url_for_material(self, slug, fmt):
+ return "%s.%s" % (slug, fmt)