backport stable 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 02 Sep 2009 10:23:38 +0200
branch3.5
changeset 3084 096d680c9da2
parent 3080 32c2b6a34ab2 (current diff)
parent 3082 99ab33abf414 (diff)
child 3085 b415bca9a9ed
child 3088 854a30d8c092
backport stable
server/session.py
web/data/cubicweb.ajax.js
web/views/boxes.py
--- a/server/session.py	Tue Sep 01 18:45:50 2009 +0200
+++ b/server/session.py	Wed Sep 02 10:23:38 2009 +0200
@@ -156,8 +156,11 @@
                 if row[0] == targeteid:
                     break
             else:
-                raise Exception('cache inconsistency for %s %s %s %s' %
-                                (eid, rtype, role, targeteid))
+                # this may occurs if the cache has been filed by a hook
+                # after the database update
+                self.debug('cache inconsistency for %s %s %s %s', eid, rtype,
+                           role, targeteid)
+                return
             del rset.rows[idx]
             if isinstance(rset.description, list): # else description not set
                 del rset.description[idx]
--- a/web/data/cubicweb.ajax.js	Tue Sep 01 18:45:50 2009 +0200
+++ b/web/data/cubicweb.ajax.js	Wed Sep 02 10:23:38 2009 +0200
@@ -395,9 +395,10 @@
 /* convenience function that returns a DOM node based on req's result. */
 function getDomFromResponse(response) {
     if (typeof(response) == 'string') {
-	return html2dom(response);
+	var doc = html2dom(response);
+    } else {
+        var doc = response.documentElement;
     }
-    var doc = response.documentElement;
     var children = doc.childNodes;
     if (!children.length) {
 	// no child (error cases) => return the whole document
--- a/web/views/boxes.py	Tue Sep 01 18:45:50 2009 +0200
+++ b/web/views/boxes.py	Wed Sep 02 10:23:38 2009 +0200
@@ -140,10 +140,13 @@
             for tr in entity.possible_transitions():
                 url = entity.absolute_url(vid='statuschange', treid=tr.eid)
                 menu_items.append(self.mk_action(_(tr.name), url))
-            wfurl = self.build_url('cwetype/%s'%entity.e_schema, vid='workflow')
-            menu_items.append(self.mk_action(_('view workflow'), wfurl))
-            wfurl = entity.absolute_url(vid='wfhistory')
-            menu_items.append(self.mk_action(_('view history'), wfurl))
+            # don't propose to see wf if user can't pass any transition
+            if menu_items:
+                wfurl = self.build_url('cwetype/%s'%entity.e_schema, vid='workflow')
+                menu_items.append(self.mk_action(_('view workflow'), wfurl))
+            if entity.workflow_history:
+                wfurl = entity.absolute_url(vid='wfhistory')
+                menu_items.append(self.mk_action(_('view history'), wfurl))
             box.append(BoxMenu(menu_title, menu_items))
         return None
 
--- a/web/views/editforms.py	Tue Sep 01 18:45:50 2009 +0200
+++ b/web/views/editforms.py	Wed Sep 02 10:23:38 2009 +0200
@@ -20,7 +20,8 @@
 from cubicweb.utils import make_uid
 from cubicweb.view import EntityView
 from cubicweb.common import tags
-from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param, uicfg
+from cubicweb.web import INTERNAL_FIELD_VALUE, RequestError, stdmsgs, eid_param
+from cubicweb.web import uicfg
 from cubicweb.web.form import FormViewMixIn, FieldNotFound
 from cubicweb.web.formfields import guess_field
 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
@@ -327,13 +328,13 @@
         """creation view for an entity"""
         etype = kwargs.pop('etype', self.req.form.get('etype'))
         try:
-            entity = self.vreg['etypes'].etype_class(etype)(self.req)
-        except:
-            self.w(self.req._('no such entity type %s') % etype)
-        else:
-            self.initialize_varmaker()
-            entity.eid = self.varmaker.next()
-            self.render_form(entity)
+            etype = self.vreg.case_insensitive_etypes[etype.lower()]
+        except KeyError:
+            raise RequestError(self.req._('no such entity type %s') % etype)
+        entity = self.vreg['etypes'].etype_class(etype)(self.req)
+        self.initialize_varmaker()
+        entity.eid = self.varmaker.next()
+        self.render_form(entity)
 
     def form_title(self, entity):
         """the form view title"""