~lifeless/python-oops-tools/bug-881400

« back to all changes in this revision

Viewing changes to src/oopstools/oops/models.py

  • Committer: Tarmac
  • Author(s): Robert Collins
  • Date: 2011-10-25 02:30:42 UTC
  • mfrom: (4.2.3 bug-879309)
  • Revision ID: launchpad@pqm.canonical.com-20111025023042-9h154ehut9sk7fbz
Handle unicode urls and missing topics better.

Show diffs side-by-side

added added

removed removed

Lines of Context:
367
367
    if most_expensive_statement is not None:
368
368
        most_expensive_statement = conform(most_expensive_statement, 200)
369
369
    url = conform(oops.get('url') or '', MAX_URL_LEN)
 
370
    if type(url) is unicode:
 
371
        # We have gotten a ringer, URL's are bytestrings. Encode to UTF8 to get
 
372
        # a bytestring and urllib.quote to get a url.
 
373
        url = urllib.quote(url.encode('utf8'))
370
374
    informational = oops.get('informational', 'False').lower() == 'true'
371
375
    oops_date = oops.get('time')
372
376
    if oops_date is None:
375
379
        oopsid = oopsid,
376
380
        prefix = prefix,
377
381
        date = oops_date.replace(microsecond=0),
378
 
        # Missing pageids are urls because that suits our queries.
379
 
        pageid = oops.get('topic') or url,
 
382
        # Missing topics are '' which will group all such reports together in
 
383
        # some ways, but thats tolerable vs something (near) unique like url:
 
384
        # that prevents aggregation.
 
385
        pageid = oops.get('topic') or '',
380
386
        url = url,
381
387
        duration = duration,
382
388
        informational = informational,