[Distutils] API for finding plugins

Ian Bicking ianb at colorstudy.com
Wed Feb 8 17:40:07 CET 2006

Phillip J. Eby wrote:
> Probably the best thing to do is going to be to require searches to be 
> prioritized on input, e.g.:
>     find_resource(
>        ('resource', ['my_page']),
>        ('for_project', ['MyProject']),
>        ('layer', ['some_layer','other_layer']),
>        ('locale', ['en','de']),
>     ...

Thoughts about the return value:

I think there should be a dictionary returned, that contains various 
metadata.  In this case it should contain at least {'resource': 
'my_page', 'for_project': 'MyProject', 'layer': 'other_layer', 'locale': 
'en'}, to represent exactly what was found.  Other metadata can be 
useful, like the resource_location (the actual filename or other 
user-readable name).  Content-type is useful in many contexts -- for 
instance, you might want some kind of image, but then you need to know 
exactly what kind you got back.  If it gets a stream, knowing 
Content-length is useful as well.  Also, either encoding should be given 
(for text resources), or unicode returns should be allowed (I prefer 
unicode return values).  I think the resource container usually knows 
the encoding, not the entity requesting the resource.

That dictionary could also be a container for callables that produce 
things like filenames and streams.  Or they could be returned in a 
different way.  Or it could be an actual object, with methods for those 
things.  Somehow I have become fond of dictionaries.

I'm starting to get a better feel for how this overlaps with templates 
-- coming at it from this direction is easier than from the WSGI direction.

Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org

More information about the Distutils-SIG mailing list