backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 17 Feb 2011 16:09:06 +0100
changeset 7006 d0f635d3a6bb
parent 7002 29f085f6177b (current diff)
parent 7005 f45f42256905 (diff)
child 7009 123947d4a875
backport stable
dbapi.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)
--- 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
--- 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 /
--- 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'
--- 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)
--- 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']