don't fail on unknown eid, simply issue a warning
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 24 Jul 2009 12:08:17 +0200
changeset 2467 6983631f5d0d
parent 2466 c4ccfd38a542
child 2468 93853b6f3bad
don't fail on unknown eid, simply issue a warning
ext/rest.py
--- 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)], []