Jesper Nøhr  committed ca114ba

error handling on reversal of resources

  • Participants
  • Parent commits 2cc125f
  • Branches default

Comments (0)

Files changed (1)

File piston/

 from django.utils import simplejson
 from django.utils.xmlutils import SimplerXMLGenerator
 from django.utils.encoding import smart_unicode
+from django.core.urlresolvers import reverse, NoReverseMatch
 from django.core.serializers.json import DateTimeAwareJSONEncoder
 from django.http import HttpResponse
 from django.core import serializers
                 handler = self.in_typemapper(type(data), self.anonymous)
                 if hasattr(handler, 'resource_uri'):
                     url_id, fields = handler.resource_uri()
-                    ret['resource_uri'] = permalink( lambda: (url_id, 
-                        (getattr(data, f) for f in fields) ) )()
+                    try:
+                        ret['resource_uri'] = permalink( lambda: (url_id, 
+                            (getattr(data, f, '') for f in fields) ) )()
+                    except NoReverseMatch:
+                        pass
             if hasattr(data, 'get_api_url') and 'resource_uri' not in ret:
                 try: ret['resource_uri'] = data.get_api_url()