backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 06 Sep 2011 12:20:09 +0200
changeset 7761 46a8cf85d186
parent 7749 cbb0a0ce3795 (current diff)
parent 7760 75d80ef524c7 (diff)
child 7762 a3f9ba4d44eb
backport stable
--- a/.hgtags	Fri Aug 05 14:23:55 2011 +0200
+++ b/.hgtags	Tue Sep 06 12:20:09 2011 +0200
@@ -220,3 +220,4 @@
 fb48c55cb80234bc0164c9bcc0e2cfc428836e5f cubicweb-debian-version-3.13.3-1
 223ecf0620b6c87d997f8011aca0d9f0ee4750af cubicweb-version-3.13.4
 52f26475d764129c5559b2d80fd57e6ea1bdd6ba cubicweb-debian-version-3.13.4-1
+a62f24e1497e953fbaed5894f6064a64f7ac0be3 cubicweb-version-3.10.x
--- a/devtools/devctl.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/devtools/devctl.py	Tue Sep 06 12:20:09 2011 +0200
@@ -88,6 +88,9 @@
             continue
         if not hasattr(mod, '__file__'):
             continue
+        if mod.__file__ is None:
+            # odd/rare but real
+            continue
         for path in config.vregistry_path():
             if mod.__file__.startswith(path):
                 del sys.modules[name]
--- a/doc/book/en/devrepo/repo/sessions.rst	Fri Aug 05 14:23:55 2011 +0200
+++ b/doc/book/en/devrepo/repo/sessions.rst	Tue Sep 06 12:20:09 2011 +0200
@@ -59,11 +59,11 @@
       other credentials elements (calling `authentication_information`),
       giving the request object each time
 
-      * the default retriever (bizarrely named
-        `LoginPaswordRetreiver`) will in turn defer login and password
-        fetching to the request object (which, depending on the
-        authentication mode (`cookie` or `http`), will do the
-        appropriate things and return a login and a password)
+      * the default retriever (oddly named `LoginPasswordRetreiver`)
+        will in turn defer login and password fetching to the request
+        object (which, depending on the authentication mode (`cookie`
+        or `http`), will do the appropriate things and return a login
+        and a password)
 
     * the authentication manager, on success, asks the `Repository`
       object to connect with the found credentials (using `connect`)
@@ -74,10 +74,10 @@
         from which a regular `Session` object is made; it returns the
         session id
 
-        * the source in turn will defer work to an authentifier class
-          that define the ultimate `authenticate` method (for instance
-          the native source will query the database against the
-          provided credentials)
+        * the source in turn will delegate work to an authentifier
+          class that defines the ultimate `authenticate` method (for
+          instance the native source will query the database against
+          the provided credentials)
 
     * the authentication manager, on success, will call back _all_
       retrievers with `authenticated` and return its authentication
@@ -99,9 +99,9 @@
 each side: some middleware will do pre-authentication and under the
 right circumstances add a new HTTP `x-foo-user` header to the query
 before it reaches the CubicWeb instance. For a concrete example of
-this, see the `apachekerberos`_ cube.
+this, see the `trustedauth`_ cube.
 
-.. _`apachekerberos`: http://www.cubicweb.org/project/cubicweb-apachekerberos
+.. _`trustedauth`: http://www.cubicweb.org/project/cubicweb-trustedauth
 
 Repository authentication plugins
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- a/doc/book/en/devweb/views/reledit.rst	Fri Aug 05 14:23:55 2011 +0200
+++ b/doc/book/en/devweb/views/reledit.rst	Tue Sep 06 12:20:09 2011 +0200
@@ -116,7 +116,34 @@
 which always work.
 
 
+Disable `reledit`
+*****************
+
+By default, `reledit` is available on attributes and relations displayed in
+the 'attribute' section of the default primary view.  If you want to disable
+it for some attribute or relation, you have use `uicfg`:
+
+.. sourcecode:: python
+
+    import uicfg.primaryview_display_ctrl as _pvdc
+    _pvdc.tag_attribute(('Company', 'name'), {'vid': 'incontext'})
+
+To deactivate it everywhere it's used automatically, you may use the code snippet
+below somewhere in your cube's views:
+
+.. sourcecode:: python
+
+    from cubicweb.web.views import reledit
+
+    class DeactivatedAutoClickAndEditFormView(reledit.AutoClickAndEditFormView):
+	def _should_edit_attribute(self, rschema):
+	    return False
+
+	def _should_edit_attribute(self, rschema, role):
+	    return False
+
+    def registration_callback(vreg):
+	vreg.register_and_replace(DeactivatedAutoClickAndEditFormView,
+				  reledit.AutoClickAndEditFormView)
 
 
-
-
--- a/i18n/de.po	Fri Aug 05 14:23:55 2011 +0200
+++ b/i18n/de.po	Tue Sep 06 12:20:09 2011 +0200
@@ -3755,7 +3755,7 @@
 msgid "site documentation"
 msgstr "Dokumentation der Website"
 
-msgid "site schema"
+msgid "data model schema"
 msgstr "Schema der Website"
 
 msgid "site title"
--- a/i18n/en.po	Fri Aug 05 14:23:55 2011 +0200
+++ b/i18n/en.po	Tue Sep 06 12:20:09 2011 +0200
@@ -3659,7 +3659,7 @@
 msgid "site documentation"
 msgstr ""
 
-msgid "site schema"
+msgid "data model schema"
 msgstr ""
 
 msgid "site title"
--- a/i18n/es.po	Fri Aug 05 14:23:55 2011 +0200
+++ b/i18n/es.po	Tue Sep 06 12:20:09 2011 +0200
@@ -3806,7 +3806,7 @@
 msgid "site documentation"
 msgstr "Documentación Sistema"
 
-msgid "site schema"
+msgid "data model schema"
 msgstr "Esquema del Sistema"
 
 msgid "site title"
--- a/i18n/fr.po	Fri Aug 05 14:23:55 2011 +0200
+++ b/i18n/fr.po	Tue Sep 06 12:20:09 2011 +0200
@@ -3806,8 +3806,8 @@
 msgid "site documentation"
 msgstr "documentation du site"
 
-msgid "site schema"
-msgstr "schéma du site"
+msgid "data model schema"
+msgstr "schéma modèle de données"
 
 msgid "site title"
 msgstr "titre du site"
--- a/server/session.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/server/session.py	Tue Sep 06 12:20:09 2011 +0200
@@ -636,12 +636,14 @@
         if txstore.ctx_count == 0:
             self._clear_thread_storage(txstore)
         else:
-            if categories:
-                if mode is self.HOOKS_DENY_ALL:
-                    return self.disable_hook_categories(*categories)
-                else:
-                    return self.enable_hook_categories(*categories)
-            self.set_hooks_mode(oldmode)
+            try:
+                if categories:
+                    if mode is self.HOOKS_DENY_ALL:
+                        return self.disable_hook_categories(*categories)
+                    else:
+                        return self.enable_hook_categories(*categories)
+            finally:
+                self.set_hooks_mode(oldmode)
 
     @property
     def disabled_hook_categories(self):
--- a/server/sources/native.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/server/sources/native.py	Tue Sep 06 12:20:09 2011 +0200
@@ -1711,21 +1711,24 @@
         archive.writestr('sequences/%s' % seq, serialized)
 
     def write_table(self, archive, table):
+        nb_lines_sql = 'SELECT COUNT(*) FROM %s' % table
+        self.cursor.execute(nb_lines_sql)
+        rowcount = self.cursor.fetchone()[0]
         sql = 'SELECT * FROM %s' % table
         columns, rows_iterator = self._get_cols_and_rows(sql)
-        self.logger.info('number of rows: %d', self.cursor.rowcount)
+        self.logger.info('number of rows: %d', rowcount)
         if table.startswith('cw_'): # entities
             blocksize = 2000
         else: # relations and metadata
             blocksize = 10000
-        if self.cursor.rowcount > 0:
-            for i, start in enumerate(xrange(0, self.cursor.rowcount, blocksize)):
+        if rowcount > 0:
+            for i, start in enumerate(xrange(0, rowcount, blocksize)):
                 rows = list(itertools.islice(rows_iterator, blocksize))
                 serialized = self._serialize(table, columns, rows)
                 archive.writestr('tables/%s.%04d' % (table, i), serialized)
                 self.logger.debug('wrote rows %d to %d (out of %d) to %s.%04d',
                                   start, start+len(rows)-1,
-                                  self.cursor.rowcount,
+                                  rowcount,
                                   table, i)
         else:
             rows = []
--- a/server/test/unittest_session.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/server/test/unittest_session.py	Tue Sep 06 12:20:09 2011 +0200
@@ -73,10 +73,20 @@
             self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
             self.assertEqual(session.disabled_hook_categories, set())
             self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
+            with hooks_control(session, session.HOOKS_ALLOW_ALL, 'integrity'):
+                self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
+                self.assertEqual(session.disabled_hook_categories, set(('integrity',)))
+                self.assertEqual(session.enabled_hook_categories, set(('metadata',))) # not changed in such case
+            self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
+            self.assertEqual(session.disabled_hook_categories, set())
+            self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
         # leaving context manager with no transaction running should reset the
         # transaction local storage (and associated cnxset)
         self.assertEqual(session._tx_data, {})
         self.assertEqual(session.cnxset, None)
+        self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
+        self.assertEqual(session.disabled_hook_categories, set())
+        self.assertEqual(session.enabled_hook_categories, set())
 
     def test_build_descr(self):
         rset = self.execute('(Any U,L WHERE U login L) UNION (Any G,N WHERE G name N, G is CWGroup)')
--- a/skeleton/__pkginfo__.py.tmpl	Fri Aug 05 14:23:55 2011 +0200
+++ b/skeleton/__pkginfo__.py.tmpl	Tue Sep 06 12:20:09 2011 +0200
@@ -18,7 +18,7 @@
 
 
 from os import listdir as _listdir
-from os.path import join, isdir, exists
+from os.path import join, isdir
 from glob import glob
 
 THIS_CUBE_DIR = join('share', 'cubicweb', 'cubes', modname)
--- a/web/formfields.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/web/formfields.py	Tue Sep 06 12:20:09 2011 +0200
@@ -148,7 +148,9 @@
        bool flag telling if this field is linked to a specific entity
     :attr:`role`
        when the field is linked to an entity attribute or relation, tells the
-       role of the entity in the relation (eg 'subject' or 'object')
+       role of the entity in the relation (eg 'subject' or 'object'). If this is
+       not an attribute or relation of the edited entity, `role` should be
+       `None`.
     :attr:`fieldset`
        optional fieldset to which this field belongs to
     :attr:`order`
--- a/web/views/schema.py	Fri Aug 05 14:23:55 2011 +0200
+++ b/web/views/schema.py	Tue Sep 06 12:20:09 2011 +0200
@@ -697,7 +697,7 @@
     __regid__ = 'schema'
     __select__ = yes()
 
-    title = _("site schema")
+    title = _("data model schema")
     order = 30
     category = 'manage'