backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 10 Mar 2011 11:58:57 +0100
changeset 7068 90ddf608fe2b
parent 7062 dca2215c5e82 (current diff)
parent 7067 f239da8e7c39 (diff)
child 7069 8bf2337a6f3b
backport stable
devtools/httptest.py
hooks/notification.py
server/repository.py
web/views/tabs.py
--- a/devtools/__init__.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/devtools/__init__.py	Thu Mar 10 11:58:57 2011 +0100
@@ -89,8 +89,11 @@
         ServerConfiguration.options +
         tuple((opt, optdict) for opt, optdict in TwistedConfiguration.options
               if opt in ('anonymous-user', 'anonymous-password')))
+    # By default anonymous login are allow but some test need to deny of to
+    # change the default user. Set it to None to prevent anonymous login.
+    anonymous_credential = ('anon', 'anon')
 
-    def __init__(self, appid, apphome=None, log_threshold=logging.CRITICAL+10):
+    def __init__(self, appid='data', apphome=None, log_threshold=logging.CRITICAL+10):
         # must be set before calling parent __init__
         if apphome is None:
             if exists(appid):
@@ -112,8 +115,10 @@
 
     def load_configuration(self):
         super(TestServerConfiguration, self).load_configuration()
-        self.global_set_option('anonymous-user', 'anon')
-        self.global_set_option('anonymous-password', 'anon')
+        if self.anonymous_credential:
+            user, password = self.anonymous_credential
+            self.global_set_option('anonymous-user', user)
+            self.global_set_option('anonymous-password', password)
         # no undo support in tests
         self.global_set_option('undo-support', '')
 
--- a/devtools/httptest.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/devtools/httptest.py	Thu Mar 10 11:58:57 2011 +0100
@@ -89,8 +89,8 @@
     """Class for running test web server. See :class:`CubicWebServerConfig`.
 
     Class attributes:
-    * ` anonymous_logged`: flag telling ifs anonymous user should be log logged
-      by default (True by default)
+    * `anonymous_logged`: flag telling if anonymous user should be logged-in
+      by default (True by default) XXX (syt) s/logged-in/allowed/ ?
     """
     configcls = CubicWebServerConfig
     # anonymous is logged by default in cubicweb test cases
@@ -189,9 +189,6 @@
 
     @classmethod
     def init_config(cls, config):
+        if not cls.anonymous_logged:
+            config.anonymous_credential = None
         super(CubicWebServerTC, cls).init_config(config)
-        if not cls.anonymous_logged:
-            config.global_set_option('anonymous-user', None)
-        else:
-            config.global_set_option('anonymous-user', 'anon')
-            config.global_set_option('anonymous-password', 'anon')
--- a/hooks/notification.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/hooks/notification.py	Thu Mar 10 11:58:57 2011 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""some hooks to handle notification on entity's changes
+"""some hooks to handle notification on entity's changes"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from logilab.common.textutils import normalize_text
--- a/server/repository.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/server/repository.py	Thu Mar 10 11:58:57 2011 +0100
@@ -536,7 +536,13 @@
             return self.config[option]
         pool = self._get_pool()
         try:
-            return pool.connection(sourceuri).get_option_value(option, extid)
+            cnx = pool.connection(sourceuri)
+            # needed to check connection is valid and usable by the current
+            # thread
+            newcnx = self.sources_by_uri[sourceuri].check_connection(cnx)
+            if newcnx is not None:
+                cnx = newcnx
+            return cnx.get_option_value(option, extid)
         finally:
             self._free_pool(pool)
 
--- a/web/views/autoform.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/web/views/autoform.py	Thu Mar 10 11:58:57 2011 +0100
@@ -785,7 +785,8 @@
     def editable_attributes(self, strict=False):
         """return a list of (relation schema, role) to edit for the entity"""
         if self.display_fields is not None:
-            return self.display_fields
+            schema = self._cw.vreg.schema
+            return [(schema[rtype], role) for rtype, role in self.display_fields]
         if self.edited_entity.has_eid() and not self.edited_entity.cw_has_perm('update'):
             return []
         # XXX we should simply put eid in the generated section, no?
--- a/web/views/tabs.py	Tue Mar 08 22:35:19 2011 +0100
+++ b/web/views/tabs.py	Thu Mar 10 11:58:57 2011 +0100
@@ -46,7 +46,9 @@
                  reloadable=False, show_spinbox=True, w=None):
         """a lazy version of wview"""
         w = w or self.w
-        urlparams = {'vid' : vid, 'fname' : 'view'}
+        self._cw.add_js('cubicweb.lazy.js')
+        urlparams = self._cw.form.copy()
+        urlparams.update({'vid' : vid, 'fname' : 'view'})
         if rql:
             urlparams['rql'] = rql
         elif eid: