[Zope] About publishing image files in python product

Chris McDonough chrism@digicool.com
Fri, 27 Apr 2001 13:20:36 -0400


> I'm writing a python product, which will publish a lot of image files as
class
> attributes. 2 problems arose:
>
> 1. All image files have to be manually declared as class attributes in the
python class
> file, which is a tedius job.
>
> 2. The declaration mentioned above doesn't allow dot in the attribute name
(it may be my
> ignorance), so 'toolbar.gif' has to be renamed to 'toolbar_gif'.
>
> I sort of found a work-around by overriding __getitem__, like this:
> def __getitem__(self, name):
>     return ImageFile('img/%s' % name, globals())
>
> It solves the problem. But after the excitement subsided, I started to
wonder why DC
> doesn't do that in the first place.

Doesn't do what where?

> Can anyone tell whether there's a huge performance
> trade-off? Is there a better way to solve the two problems?

If I understand the problem, your method seems fine...