get_all_records does not return records with their attachments

Bug #702007 reported by Manuel de la Peña
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
desktopcouch
Confirmed
Medium
Ubuntu One Client Engineering team
desktopcouch (Ubuntu)
Confirmed
Medium
Ubuntu One Client Engineering team
Natty
Won't Fix
Medium
Ubuntu One Client Engineering team

Bug Description

The get_all_records function relies on the transform_to_records function to convert the view results to Records. There is a bug on transform_to_records because it does not handle the situation in which the record has an attachment. Attahcments from views are returned as stubs in the '_attachments' keyword, but such special case is ignored in the Record constructor because it would require to know the db from which the record was created. To solve this issue the transform_to_records function should perform a similar job as the one found in get_record(id), otherwhise developers will find that the attachments from the record cannot be retrieved and will get a KeyError.

Tags: u1-natty-sru
Changed in desktopcouch:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Stuart Langridge (sil) wrote :

Note that you can sort of work around this with recordobject._data, which will have an _attachments key containing metadata (but not data) for attachments. This is of course using internal data structures and undocumented, but you can at least see the names of attachments on a record.

Revision history for this message
Eric Casteleijn (thisfred) wrote :

# demo of weirdness
dic = {
    'spouse_name': '',
    'last_name': 'Smith',
    'middle_name': '',
    'suffix': '',
    'application_annotations': {
        'Funambol Exchange': {
            'private_application_annotations': {
                'created_timestamp': 1282566126030L,
                'exchange_hash': '3a670a52a2a43466fe1c71e50e4ed617',
                'email': '84aa15b7-f8e2-41e7-ba8f-60b25e302022'
            },
            'application_fields': {
                'photo': '',
                'state': 'N',
                'urlWork': '',
                'children': '',
                'urlHome': ''
            }
        }
    },
    'title': '',
    'nick_name': '',
    '_rev': '3-4ac012ecab57171fc22aab4853054f8f',
    'first_name': 'Minh',
    '_attachments': {
        'photo': {
            'stub': True,
            'length': 4631,
            'revpos': 3,
            'content_type': 'image/png'
        }
    },
    'record_type': 'http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact',
    'department': '',
    '_id': '0167decee3fd4193b551231f12033033',
    'company': '',
    'notes': '',
    'email_addresses': {
        '84aa15b7-f8e2-41e7-ba8f-60b25e302022': {
            'description': 'other',
            'address': '<email address hidden>'
        },
        '_order': ['84aa15b7-f8e2-41e7-ba8f-60b25e302022']
    },
    'job_title': ''
}

r = Record(dic)
print r._attachments

Changed in desktopcouch:
assignee: nobody → Eric Casteleijn (thisfred)
Changed in desktopcouch (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Eric Casteleijn (thisfred)
milestone: none → ubuntu-11.04-beta-1
tags: added: u1-natty
Changed in desktopcouch (Ubuntu Natty):
milestone: ubuntu-11.04-beta-1 → ubuntu-11.04-beta-2
Changed in desktopcouch (Ubuntu Natty):
milestone: ubuntu-11.04-beta-2 → natty-updates
tags: added: u1-natty-sru
removed: u1-natty
Changed in desktopcouch:
assignee: Eric Casteleijn (thisfred) → Ubuntu One Desktop+ team (ubuntuone-desktop+)
Changed in desktopcouch (Ubuntu):
assignee: Eric Casteleijn (thisfred) → Ubuntu One Desktop+ team (ubuntuone-desktop+)
Changed in desktopcouch (Ubuntu Natty):
assignee: Eric Casteleijn (thisfred) → Ubuntu One Desktop+ team (ubuntuone-desktop+)
Changed in desktopcouch (Ubuntu):
milestone: natty-updates → none
Changed in desktopcouch (Ubuntu Natty):
milestone: natty-updates → none
Revision history for this message
Rolf Leggewie (r0lf) wrote :

natty has seen the end of its life and is no longer receiving any updates. Marking the natty task for this ticket as "Won't Fix".

Changed in desktopcouch (Ubuntu Natty):
status: Confirmed → Won't Fix
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.