[merge] backport stable fixes
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 18 Jan 2013 18:31:51 +0100
changeset 8660 aa865f3be80d
parent 8658 11707295d4e6 (current diff)
parent 8659 cd9fddc21361 (diff)
child 8661 4d24ac49f90d
[merge] backport stable fixes
entities/test/unittest_wfobjs.py
entity.py
--- a/entities/test/unittest_wfobjs.py	Fri Jan 18 16:40:11 2013 +0100
+++ b/entities/test/unittest_wfobjs.py	Fri Jan 18 18:31:51 2013 +0100
@@ -54,7 +54,8 @@
         wf.add_state(u'foo')
         with self.assertRaises(ValidationError) as cm:
             self.commit()
-        self.assertEqual(cm.exception.errors, {'name-subject': 'workflow already have a state of that name'})
+        self.assertEqual({'name-subject': 'workflow already has a state of that name'},
+                         cm.exception.errors)
         # no pb if not in the same workflow
         wf2 = add_wf(self, 'Company')
         foo = wf2.add_state(u'foo', initial=True)
@@ -65,7 +66,8 @@
         bar.cw_set(name=u'foo')
         with self.assertRaises(ValidationError) as cm:
             self.commit()
-        self.assertEqual(cm.exception.errors, {'name-subject': 'workflow already have a state of that name'})
+        self.assertEqual({'name-subject': 'workflow already has a state of that name'},
+                         cm.exception.errors)
 
     def test_duplicated_transition(self):
         wf = add_wf(self, 'Company')
--- a/entity.py	Fri Jan 18 16:40:11 2013 +0100
+++ b/entity.py	Fri Jan 18 18:31:51 2013 +0100
@@ -579,10 +579,8 @@
         """custom json dumps hook to dump the entity's eid
         which is not part of dict structure itself
         """
-        self.complete()
         dumpable = self.cw_attr_cache.copy()
         dumpable['eid'] = self.eid
-        dumpable['__cwetype__'] = self.__regid__
         return dumpable
 
     def cw_adapt_to(self, interface):
--- a/schemas/workflow.py	Fri Jan 18 16:40:11 2013 +0100
+++ b/schemas/workflow.py	Fri Jan 18 18:31:51 2013 +0100
@@ -66,7 +66,7 @@
     name = String(required=True, indexed=True, internationalizable=True,
                   maxsize=256,
                   constraints=[RQLUniqueConstraint('S name N, S state_of WF, Y state_of WF, Y name N', 'Y',
-                                                   _('workflow already have a state of that name'))])
+                                                   _('workflow already has a state of that name'))])
     description = RichString(default_format='text/rest',
                              description=_('semantic description of this state'))
 
--- a/web/views/json.py	Fri Jan 18 16:40:11 2013 +0100
+++ b/web/views/json.py	Fri Jan 18 18:31:51 2013 +0100
@@ -111,7 +111,12 @@
     title = _('json-entities-export-view')
 
     def call(self):
-        if self.cw_rset is None:
-            self.wdata([self.cw_extra_kwargs.get('entity')])
-        else:
-            self.wdata(list(self.cw_rset.entities()))
+        entities = []
+        for entity in self.cw_rset.entities():
+            entity.complete() # fetch all attributes
+            # hack to add extra metadata
+            entity.cw_attr_cache.update({
+                    '__cwetype__': entity.__regid__,
+                    })
+            entities.append(entity)
+        self.wdata(entities)