# HG changeset patch # User Sylvain Thénault # Date 1297955346 -3600 # Node ID d0f635d3a6bb3a7bb5f09078b24f9206751f716e # Parent 29f085f6177b973584c5114b49c786fa03f46608# Parent f45f422569051cf2e02632ef239d813b328dc9c6 backport stable diff -r 29f085f6177b -r d0f635d3a6bb cwconfig.py --- a/cwconfig.py Thu Feb 17 10:26:50 2011 +0100 +++ b/cwconfig.py Thu Feb 17 16:09:06 2011 +0100 @@ -587,6 +587,14 @@ return # cubes dir doesn't exists @classmethod + def load_available_configs(cls): + from logilab.common.modutils import load_module_from_file + for conffile in ('web/webconfig.py', 'etwist/twconfig.py', + 'server/serverconfig.py',): + if exists(join(CW_SOFTWARE_ROOT, conffile)): + load_module_from_file(join(CW_SOFTWARE_ROOT, conffile)) + + @classmethod def load_cwctl_plugins(cls): from logilab.common.modutils import load_module_from_file cls.cls_adjust_sys_path() @@ -597,8 +605,8 @@ try: load_module_from_file(join(CW_SOFTWARE_ROOT, ctlfile)) except ImportError, err: - cls.info('could not import the command provider %s (cause : %s)' % - (ctlfile, err)) + cls.error('could not import the command provider %s: %s', + ctlfile, err) cls.info('loaded cubicweb-ctl plugin %s', ctlfile) for cube in cls.available_cubes(): oldpluginfile = join(cls.cube_dir(cube), 'ecplugin.py') @@ -895,6 +903,7 @@ def config_for(cls, appid, config=None, debugmode=False): """return a configuration instance for the given instance identifier """ + cls.load_available_configs() config = config or guess_configuration(cls.instance_home(appid)) configcls = configuration_cls(config) return configcls(appid, debugmode) diff -r 29f085f6177b -r d0f635d3a6bb dbapi.py --- a/dbapi.py Thu Feb 17 10:26:50 2011 +0100 +++ b/dbapi.py Thu Feb 17 16:09:06 2011 +0100 @@ -168,16 +168,20 @@ where it's already initialized. :kwargs: - there goes authentication tokens. You usually have to specify for - instance a password for the given user, using a named 'password' argument. + there goes authentication tokens. You usually have to specify a password + for the given user, using a named 'password' argument. """ - config = cwconfig.CubicWebNoAppConfiguration() - if host: - config.global_set_option('pyro-ns-host', host) - if group: - config.global_set_option('pyro-ns-group', group) cnxprops = cnxprops or ConnectionProperties() method = cnxprops.cnxtype + if method == 'pyro': + config = cwconfig.CubicWebNoAppConfiguration() + if host: + config.global_set_option('pyro-ns-host', host) + if group: + config.global_set_option('pyro-ns-group', group) + else: + assert database + config = cwconfig.instance_configuration(database) repo = get_repository(method, database, config=config) if method == 'inmemory': vreg = repo.vreg diff -r 29f085f6177b -r d0f635d3a6bb server/hook.py --- a/server/hook.py Thu Feb 17 10:26:50 2011 +0100 +++ b/server/hook.py Thu Feb 17 16:09:06 2011 +0100 @@ -844,6 +844,12 @@ postcommit method of the operation.""" _container_add(self._container, data) + def remove_data(self, data): + assert not self._processed, """Trying to add data to a closed operation. +Iterating over operation data closed it and should be reserved to precommit / +postcommit method of the operation.""" + self._container.remove(data) + def get_data(self): assert not self._processed, """Trying to get data from a closed operation. Iterating over operation data closed it and should be reserved to precommit / diff -r 29f085f6177b -r d0f635d3a6bb skeleton/__pkginfo__.py.tmpl --- a/skeleton/__pkginfo__.py.tmpl Thu Feb 17 10:26:50 2011 +0100 +++ b/skeleton/__pkginfo__.py.tmpl Thu Feb 17 16:09:06 2011 +0100 @@ -1,4 +1,4 @@ -# pylint: disable-msg=W0622 +# pylint: disable=W0622 """%(distname)s application packaging information""" modname = '%(cubename)s' diff -r 29f085f6177b -r d0f635d3a6bb web/test/unittest_views_navigation.py --- a/web/test/unittest_views_navigation.py Thu Feb 17 10:26:50 2011 +0100 +++ b/web/test/unittest_views_navigation.py Thu Feb 17 16:09:06 2011 +0100 @@ -58,7 +58,7 @@ navcomp = self.vreg['components'].select('navigation', req, rset=rset, page_size=20) self.assertIsInstance(navcomp, PageNavigationSelect) - def test_navigation_selection_not_enough(self): + def test_navigation_selection_not_enough_1(self): req = self.request() rset = self.execute('Any X,N LIMIT 10 WHERE X name N') navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) @@ -68,7 +68,7 @@ self.assertEqual(navcomp, None) req.set_search_state('normal') - def test_navigation_selection_not_enough(self): + def test_navigation_selection_not_enough_2(self): req = self.request() rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') navcomp = self.vreg['components'].select('navigation', req, rset=rset) diff -r 29f085f6177b -r d0f635d3a6bb web/views/wdoc.py --- a/web/views/wdoc.py Thu Feb 17 10:26:50 2011 +0100 +++ b/web/views/wdoc.py Thu Feb 17 16:09:06 2011 +0100 @@ -92,9 +92,14 @@ return index def title_for_lang(node, lang): + fallback_title = None for title in node.findall('title'): - if title.attrib['{http://www.w3.org/XML/1998/namespace}lang'] == lang: + title_lang = title.attrib['{http://www.w3.org/XML/1998/namespace}lang'] + if title_lang == lang: return unicode(title.text) + if title_lang == 'en': + fallback_title = unicode(title.text) + return fallback_title def subsections(node): return [child for child in node if child.tag == 'section']