comment.attachments crashes in HTML connector

Bug #215043 reported by Daniel Holbach
2
Affects Status Importance Assigned to Milestone
python-launchpad-bugs
Fix Released
Undecided
Markus Korn

Bug Description

>>> import launchpadbugs.connector as Connector
>>> Bug = Connector.ConnectBug()
>>> b = Bug(135425)
>>> print b.comments[0].attachments
set([Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/launchpadbugs/attachmentsbase.py", line 59, in __repr__
    if self.is_down:
  File "/usr/lib/python2.5/site-packages/launchpadbugs/attachmentsbase.py", line 93, in is_down
    self.sourcepackage, str(self.bugnumber),
  File "/usr/lib/python2.5/site-packages/launchpadbugs/lphelper.py", line 261, in <lambda>
    if fget : fget = lambda s, n=fget.__name__ : getattr(s, n)()
  File "/usr/lib/python2.5/site-packages/launchpadbugs/html_bug.py", line 602, in get_sourcepackage
    return self.edit_url.split("/")[-5]
  File "/usr/lib/python2.5/site-packages/launchpadbugs/lphelper.py", line 261, in <lambda>
    if fget : fget = lambda s, n=fget.__name__ : getattr(s, n)()
  File "/usr/lib/python2.5/site-packages/launchpadbugs/html_bug.py", line 606, in get_edit_url
    return utils.valid_lp_url(self._edit, utils.BUG)
AttributeError: 'Attachment' object has no attribute '_edit'
>>>

Markus Korn (thekorn)
Changed in python-launchpad-bugs:
assignee: nobody → thekorn
status: New → In Progress
Revision history for this message
Markus Korn (thekorn) wrote :

The main problem here is that the attachments have to be parsed before they can be shown via b.comments[0].attachemnts.

A workaround is
In [23]: b = Bug(135425)

In [24]: b.attachments
Out[24]: <Attachmentlist>

In [25]: print b.comments[0].attachments
set([<Attachment (up: #9038689)>])

Fixing this should be a one-liner, will work on it this evening.

When I understood you correct, you would like to know when a certain file was attached. I Always thought you can get this by running:

b = bug(123456)
x = b.attachments[0]
print b.comments[x.comment].date

But obviously the .comment attribute of an Attachment-object got lost somewhere, I'm pretty sure this worked somewhere in the past.
I think I will also fix this.

Markus

Revision history for this message
Markus Korn (thekorn) wrote :

this patch against .main rev 87 should fix this bug. It also fixes the way of getting the date when an attachment was created.

Please review and test it with other bug-reports.

Markus

Revision history for this message
Daniel Holbach (dholbach) wrote :

It looks very very good. Should definitely be committed.

How can we get this working for the text interface? If it's necessary to file bugs on malone, I'm happy to do that. :-)

Revision history for this message
Markus Korn (thekorn) wrote :

------------------------------------------------------------
revno: 88
committer: Markus Korn <email address hidden>
branch nick: main
timestamp: Wed 2008-04-16 09:39:29 +0200
message:
  * launchpadbugs/attachmentsbase.py, launchpadbugs/html_bug.py:
    always parse attachments before parsing comments in the html-mode.
    (LP: #215043)
------------------------------------------------------------
To have the same functionality in the text mode, py-lp-bugs needs to know which attachment was added by which comment. This information is not provided in the +text view. Attachments are there only mentioned in the very first stanza but not in the related comment.

Markus

Changed in python-launchpad-bugs:
status: In Progress → Fix Committed
Revision history for this message
Brian Murray (brian-murray) wrote :

This is fixed in the bzr branch of python-launchpad-bugs in addition to do Intrepid package versions => 0.2.31.

Changed in python-launchpad-bugs:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.