Ticket #7027 (closed Bug: fixed)

Opened 9 years ago

Last modified 9 years ago

CMFFormControler.ControllerState.__str__ loads files in memory

Reported by: zegor Owned by:
Priority: critical Milestone: 2.5.4
Component: General Version:
Keywords: CMFFormControler Cc:


When dealing with big files (> 100 GO), Editing a ATFile is slow and consumme a lot of memory.

I found that there is a side effect in method CMFFormControler.ControllerState.str. This method calls str(self.getContext()). When context is an ATFile (or any content type whith a FileField), str loads the file into memory ! When editing an ATFile, this method is called 10 times !!

So replacing str by repr is a VERY big optimization.

   def __str__(self):
        return 'id = %s\nstatus = %s\nbutton=%s\nerrors=%s\ncontext=%s\nkwargs=%s\nnext_action=%s\n' % \
            (self.id, str(self.getStatus()), str(self.getButton()),
             str(self.getErrors()), repr(self.getContext()),
             str(self.kwargs), str(self.next_action))

Change History

comment:1 Changed 9 years ago by zegor

Oups, file sizes are 100 MO, not 100 GO ;-)

comment:2 Changed 9 years ago by zegor

Correction commited on CMFFormControler/trunk

comment:3 Changed 9 years ago by limi

  • Priority changed from major to critical
  • Milestone changed from 3.0.x to 2.5.x

That means it goes into Plone 3.0.x, but we should probably include it in 2.5.x too.

Changeset is here:  http://dev.plone.org/collective/changeset/49070

Alec, can you apply this to whatever branch of CMFFC 2.5.x uses, if applicable?


comment:4 Changed 9 years ago by alecm

  • Status changed from new to closed
  • Resolution set to fixed

comment:5 Changed 4 years ago by davisagli

  • Component changed from Infrastructure to General
Note: See TracTickets for help on using tickets.