[dbapi] web request compatibility fixes
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 25 Oct 2010 10:15:47 +0200
changeset 6613 e7ff604491b2
parent 6612 2f2871fbfb51
child 6614 4b9a785df0f7
[dbapi] web request compatibility fixes
dbapi.py
test/unittest_dbapi.py
--- a/dbapi.py	Mon Oct 25 10:14:01 2010 +0200
+++ b/dbapi.py	Mon Oct 25 10:15:47 2010 +0200
@@ -570,6 +570,7 @@
             req.get_header = lambda x, default=None: default
             req.set_session = lambda session, user=None: DBAPIRequest.set_session(
                 req, session, user)
+            req.relative_path = lambda includeparams=True: ''
         else:
             req = DBAPIRequest(self.vreg)
         req.set_session(DBAPISession(self))
--- a/test/unittest_dbapi.py	Mon Oct 25 10:14:01 2010 +0200
+++ b/test/unittest_dbapi.py	Mon Oct 25 10:15:47 2010 +0200
@@ -76,7 +76,10 @@
             self.cnx.use_web_compatible_requests('http://perdu.com')
             req = self.cnx.request()
             self.assertEqual(req.base_url(), 'http://perdu.com')
+            self.assertEqual(req.from_controller(), 'view')
+            self.assertEqual(req.relative_path(), '')
             req.ajax_replace_url('domid') # don't crash
+            req.user.cw_adapt_to('IBreadCrumbs') # don't crash
 
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main