https://www.logilab.net/cwo/ticket/343724 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 19 Jun 2009 09:19:27 +0200
branchstable
changeset 2125 19861294506f
parent 2124 5a0b02f37b23
child 2130 caa5acbecc08
child 2172 cf8f9180e63e
https://www.logilab.net/cwo/ticket/343724
entity.py
test/unittest_entity.py
--- a/entity.py	Fri Jun 19 08:47:05 2009 +0200
+++ b/entity.py	Fri Jun 19 09:19:27 2009 +0200
@@ -398,7 +398,7 @@
         path = etype.lower()
         if mainattr != 'eid':
             value = getattr(self, mainattr)
-            if value is None:
+            if value is None or unicode(value) == u'':
                 mainattr = 'eid'
                 path += '/eid'
             elif needcheck:
--- a/test/unittest_entity.py	Fri Jun 19 08:47:05 2009 +0200
+++ b/test/unittest_entity.py	Fri Jun 19 09:19:27 2009 +0200
@@ -390,6 +390,11 @@
         metainf['extid']  = 1234
         self.assertEquals(note.absolute_url(), 'http://cubicweb2.com/note/1234')
 
+    def test_absolute_url_empty_field(self):
+        card = self.add_entity('Card', wikiid=u'', title=u'test')
+        self.assertEquals(card.absolute_url(),
+                          'http://testing.fr/cubicweb/card/eid/%s' % card.eid)
+
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main
     unittest_main()