backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Jun 2011 16:04:01 +0200
changeset 7574 34154f48d255
parent 7570 648bf83945a5 (current diff)
parent 7573 c8f8762c986d (diff)
child 7575 335f14e8e5a7
backport stable
server/__init__.py
server/repository.py
server/session.py
web/data/cubicweb.ajax.js
web/formfields.py
--- a/server/__init__.py	Tue Jun 28 17:59:31 2011 +0200
+++ b/server/__init__.py	Wed Jun 29 16:04:01 2011 +0200
@@ -36,6 +36,12 @@
 
 from cubicweb import CW_SOFTWARE_ROOT
 
+class ShuttingDown(BaseException):
+    """raised when trying to access some resources while the repository is
+    shutting down. Inherit from BaseException so that `except Exception` won't
+    catch it.
+    """
+
 # server-side debugging #########################################################
 
 # server debugging flags. They may be combined using binary operators.
--- a/server/repository.py	Tue Jun 28 17:59:31 2011 +0200
+++ b/server/repository.py	Wed Jun 29 16:04:01 2011 +0200
@@ -55,7 +55,7 @@
                       BadConnectionId, Unauthorized, ValidationError,
                       RepositoryError, UniqueTogetherError, typed_eid, onevent)
 from cubicweb import cwvreg, schema, server
-from cubicweb.server import utils, hook, pool, querier, sources
+from cubicweb.server import ShuttingDown, utils, hook, pool, querier, sources
 from cubicweb.server.session import Session, InternalSession, InternalManager, \
      security_enabled
 from cubicweb.server.ssplanner import EditedEntity
@@ -942,7 +942,7 @@
                      checkshuttingdown=True):
         """return the user associated to the given session identifier"""
         if checkshuttingdown and self.shutting_down:
-            raise Exception('Repository is shutting down')
+            raise ShuttingDown('Repository is shutting down')
         try:
             session = self._sessions[sessionid]
         except KeyError:
--- a/server/session.py	Tue Jun 28 17:59:31 2011 +0200
+++ b/server/session.py	Wed Jun 29 16:04:01 2011 +0200
@@ -38,6 +38,7 @@
 from cubicweb.dbapi import ConnectionProperties
 from cubicweb.utils import make_uid, RepeatList
 from cubicweb.rqlrewrite import RQLRewriter
+from cubicweb.server import ShuttingDown
 from cubicweb.server.edition import EditedEntity
 
 
@@ -1287,7 +1288,7 @@
         """connections set, set according to transaction mode for each query"""
         if self.repo.shutting_down:
             self.free_cnxset(True)
-            raise Exception('repository is shutting down')
+            raise ShuttingDown('repository is shutting down')
         return getattr(self._threaddata, 'cnxset', None)
 
 
--- a/server/utils.py	Tue Jun 28 17:59:31 2011 +0200
+++ b/server/utils.py	Wed Jun 29 16:04:01 2011 +0200
@@ -128,14 +128,18 @@
                              (interval, func_name(func)))
         self.interval = interval
         def auto_restart_func(self=self, func=func, args=args):
+            restart = True
             try:
                 func(*args)
-            except:
+            except Exception:
                 logger = logging.getLogger('cubicweb.repository')
                 logger.exception('Unhandled exception in LoopTask %s', self.name)
                 raise
+            except BaseException:
+                restart = False
             finally:
-                self.start()
+                if restart:
+                    self.start()
         self.func = auto_restart_func
         self.name = func_name(func)
 
--- a/web/data/cubicweb.ajax.js	Tue Jun 28 17:59:31 2011 +0200
+++ b/web/data/cubicweb.ajax.js	Wed Jun 29 16:04:01 2011 +0200
@@ -296,7 +296,7 @@
 }
 
 /**
- * .. function:: loadxhtml(url, form, reqtype='get', mode='replace', cursor=true)
+ * .. function:: loadxhtml(url, form, reqtype='get', mode='replace', cursor=false)
  *
  * build url given by absolute or relative `url` and `form` parameters
  * (dictionary), fetch it using `reqtype` method, then evaluate the
@@ -312,7 +312,9 @@
  */
 jQuery.fn.loadxhtml = function(url, form, reqtype, mode, cursor) {
     if (this.size() > 1) {
-        cw.log('loadxhtml was called with more than one element');
+        cw.log('loadxhtml called with more than one element');
+    } else if (this.size() < 1) {
+        cw.log('loadxhtml called without an element');
     }
     var callback = null;
     if (form && form.callback) {
--- a/web/formfields.py	Tue Jun 28 17:59:31 2011 +0200
+++ b/web/formfields.py	Wed Jun 29 16:04:01 2011 +0200
@@ -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.
@@ -387,12 +387,11 @@
         """
         assert self.choices is not None
         if callable(self.choices):
-            try:
-                if getattr(self.choices, 'im_self', None) is self:
-                    vocab = self.choices(form=form, **kwargs)
-                else:
-                    vocab = self.choices(form=form, field=self, **kwargs)
-            except TypeError:
+            if getattr(self.choices, 'im_self', None) is self:
+                vocab = self.choices(form=form, **kwargs)
+            elif support_args(self.choices, 'form', 'field'):
+                vocab = self.choices(form=form, field=self, **kwargs)
+            else:
                 try:
                     vocab = self.choices(form=form, **kwargs)
                     warn('[3.6]  %s: choices should now take '