[Zope] Re: ImageFile weirdness?

Chris Withers chris at simplistix.co.uk
Wed Mar 1 13:38:59 EST 2006


Jürgen Herrmann wrote:
> to not clutter the zodb-dev list, i'll write you personally...

It's what the list is here for, please keep CC'ing it or you're unlikely 
to get a response in the future...

> arent't these two code snippets doing the same?
> 
> class MyClass:
>   myTemplate = PageTemplateFile(...)
> 
> and:
> 
> class MyClass:
>   def initTemplates(self):
>     myTemplate = PageTemplateFile(...)
>     setattr(self.__class__, 'myTemplate', myTemplate)
> # calling initTemplates() once at startup.

Almost certainly not. I have no idea where 'self' in your second example 
comes from, but I'd almost bet it isn't what you expect...

> i'm actually doing this since long,

That doesn't make it right ;-)

> because i initialize page template
> files found in a certain directory by calling initTemplates() once on
> zope startup. this way i don't have to add a line for each template,
> the code simply iterates over all .pt files in the directory...

Interesting, but there are likely to be problems with it. Not least of 
which: how are you adding security declarations for those new methods?

> actually i have fixed my initial problem by replacing ImageFile with
> ExternalFile, which behaves differently and sets the correct content-
> type headers if it has a content_type property.

That doesn't sounds like such a hot idea. My understanding was that 
ExternalFile was for storing _content_ files on the filesystem...

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list