--- 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()