[PATCH] fix reading attachments data

Vladimir Prus ghost at cs.msu.su
Mon Jul 14 12:25:58 UTC 2003


Hello,
I think reading of attachment data is broken in HEAD.

I have

 arguments = [
        qm.fields.AttachmentField(
            name="history",

and later:

        expected_trace = self.history.GetData()

The last line does not work:

   exceptions.IOError: [Errno 2] No such file or directory:  
      'history.qms/test13.itrace' 

I think it's caused by this change:
  
2003-01-03  Mark Mitchell  <mark at codesourcery.com>

        * qm/test/database.py (ItemDescriptor.__init__): Do not set
        __working_directory.
        (ItemDescriptor.SetWorkingDirectory): Remove.
        (ItemDescriptor.GetWorkingDirectory): Likewise.
        (ItemDescriptor._Execute): Do not change directories.
        * qm/test/classes/xml_database.py (XMLDatabase.__LoadItem): Do not
        use SetWorkingDirectory.

The FileAttachmentStore does not know its own location, and all attachments 
are stored using relative location to test db. Since there's no change of 
directory now, opening of attachment files does not work.

Actually, I'm not sure why the above change was made (and changelog does not 
say about motivation), but assuming it's for a good reason, the attached 
patch fixed the problem I've run into.

Changelog entry:

Fix reading of attachment data.

* qm/attachment.py: 
   (FileAttachmentStore.__init__): New argument 'root'.
   (FileAttachmentStore.GetDataFile): Treat location as relative to
     'self.root'.
   (TemporaryAttachmentStore.__init__): Pass own path to parent's __init__.

* qm/test/classes/xml_database.py
   (XMLDatabase.__init__): Pass path to FileAttachmentStore.__init__

Patch attached.

- Volodya
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attachments.diff
Type: text/x-diff
Size: 2265 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/qmtest/attachments/20030714/d043ce71/attachment.diff>


More information about the qmtest mailing list