ext/rest.py
changeset 2467 6983631f5d0d
parent 2312 af4d8f75c5db
child 2680 66472d85d548
--- a/ext/rest.py	Fri Jul 24 10:36:57 2009 +0200
+++ b/ext/rest.py	Fri Jul 24 12:08:17 2009 +0200
@@ -31,6 +31,7 @@
 
 from logilab.mtconverter import ESC_UCAR_TABLE, ESC_CAR_TABLE, xml_escape
 
+from cubicweb import UnknownEid
 from cubicweb.ext.html4zope import Writer
 
 # We provide our own parser as an attempt to get rid of
@@ -68,8 +69,13 @@
         return [prb], [msg]
     # Base URL mainly used by inliner.pep_reference; so this is correct:
     context = inliner.document.settings.context
-    refedentity = context.req.eid_rset(eid_num).get_entity(0, 0)
-    ref = refedentity.absolute_url()
+    try:
+        refedentity = context.req.eid_rset(eid_num).get_entity(0, 0)
+    except UnknownEid:
+        ref = '#'
+        rest += u' ' + context.req._('(UNEXISTANT EID)')
+    else:
+        ref = refedentity.absolute_url()
     set_classes(options)
     return [nodes.reference(rawtext, utils.unescape(rest), refuri=ref,
                             **options)], []