# HG changeset patch # User Sylvain Thénault # Date 1309356241 -7200 # Node ID 34154f48d255287e244f8d8edb7de2cc6483903b # Parent 648bf83945a5823ee80ae7826a5c70ee58151440# Parent c8f8762c986d23f3762fa739c4990d2df1a930bd backport stable diff -r 648bf83945a5 -r 34154f48d255 server/__init__.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. diff -r 648bf83945a5 -r 34154f48d255 server/repository.py --- 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: diff -r 648bf83945a5 -r 34154f48d255 server/session.py --- 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) diff -r 648bf83945a5 -r 34154f48d255 server/utils.py --- 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) diff -r 648bf83945a5 -r 34154f48d255 web/data/cubicweb.ajax.js --- 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) { diff -r 648bf83945a5 -r 34154f48d255 web/formfields.py --- 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 '