Am 10.02.2009 um 10:16 schrieb Charlie Clark:

> Now the profile results:
> 1) View
>  4499 function calls (4476 primitive calls) in 0.110 CPU seconds
> 2) PythonScript
>  12830 function calls (12786 primitive calls) in 0.154 CPU seconds

I've added an interator which reduces the number of calls:

  2370 function calls (2362 primitive calls) in 0.041 CPU seconds

But this reduces data transfer still further to between 10 and 20 MB/s!

While I'm convinced that the code is probably better I'm at a loss  
about the slowdown. This is the code for comments:

class FilesIterator(object):

     size = 0
     files = []

     def __init__(self, files):
         for f, size in files:
             self.size += size

     def next(self):
         while self.files:
             f = open(self.files.pop(), "rb")
             data =
             return data

class Javascript(ViewBase):
     """Return all Javascript from the skin as a single string"""

     folder_name = 'js'
     content_type = 'application/x-javascript'

     def contents(self):
         skin_tool = getToolByName(self.context, 'portal_skins')
         layer = skin_tool.getDefaultSkin()
         skin = skin_tool.getSkinByName(layer)
         folder = getattr(skin, self.folder_name)
         obs = [(ob._filepath, ob.get_size()) for ob in  
                        if ob.meta_type == "Filesystem File"]
         fs = FilesIterator(obs)
         return fs

     def __call__(self):
         bundle = self.contents()
         self.request.response.setHeader("Content-Length", bundle.size)
         data =
         while data:
             data =

I did look at the file_iterator in ZPublisher.Iterators but I couldn't  
see a way to combine that with a list of files.

Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to