app/soc/logic/models/base.py
changeset 2346 d830123c1be1
parent 2230 f3d59025d254
child 2364 a1cbd3143277
equal deleted inserted replaced
2345:f78caf12f32d 2346:d830123c1be1
    23   '"Lennard de Rijk" <ljvderijk@gmail.com>',
    23   '"Lennard de Rijk" <ljvderijk@gmail.com>',
    24   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    24   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    25   ]
    25   ]
    26 
    26 
    27 
    27 
       
    28 import logging
       
    29 
    28 from google.appengine.ext import db
    30 from google.appengine.ext import db
    29 
    31 
    30 from django.utils.translation import ugettext
    32 from django.utils.translation import ugettext
    31 
    33 
    32 from soc.cache import sidebar
    34 from soc.cache import sidebar
   322     if unique:
   324     if unique:
   323       limit = 1
   325       limit = 1
   324 
   326 
   325     query = self.getQueryForFields(filter=filter, order=order)
   327     query = self.getQueryForFields(filter=filter, order=order)
   326 
   328 
   327     result = query.fetch(limit, offset)
   329     try:
       
   330       result = query.fetch(limit, offset)
       
   331     except db.NeedIndexError, exception:
       
   332       result = []
       
   333       logging.exception("%s, model: %s filter: %s, order: %s" % 
       
   334                         (exception, self._model, filter, order))
       
   335       # TODO: send email
   328 
   336 
   329     if unique:
   337     if unique:
   330       return result[0] if result else None
   338       return result[0] if result else None
   331 
   339 
   332     return result
   340     return result