cubicweb/web/test/unittest_views_basecontrollers.py
changeset 12567 26744ad37953
parent 12503 b01dd0ef43aa
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """cubicweb.web.views.basecontrollers unit tests"""
    18 """cubicweb.web.views.basecontrollers unit tests"""
    19 
    19 
    20 import time
    20 import time
    21 
    21 from urllib.parse import urlsplit, urlunsplit, urljoin, parse_qs
    22 from six import text_type
       
    23 from six.moves.urllib.parse import urlsplit, urlunsplit, urljoin, parse_qs
       
    24 
    22 
    25 import lxml
    23 import lxml
    26 
    24 
    27 from logilab.common.testlib import unittest_main
    25 from logilab.common.testlib import unittest_main
    28 
    26 
    90                         'upassword-subject:X': u'toto',
    88                         'upassword-subject:X': u'toto',
    91                         'upassword-subject-confirm:X': u'toto',
    89                         'upassword-subject-confirm:X': u'toto',
    92                     }
    90                     }
    93             with self.assertRaises(ValidationError) as cm:
    91             with self.assertRaises(ValidationError) as cm:
    94                 self.ctrl_publish(req)
    92                 self.ctrl_publish(req)
    95             cm.exception.translate(text_type)
    93             cm.exception.translate(str)
    96             expected = {
    94             expected = {
    97                 '': u'some relations violate a unicity constraint',
    95                 '': u'some relations violate a unicity constraint',
    98                 'login': u'login is part of violated unicity constraint',
    96                 'login': u'login is part of violated unicity constraint',
    99             }
    97             }
   100             self.assertEqual(cm.exception.errors, expected)
    98             self.assertEqual(cm.exception.errors, expected)
   147         """
   145         """
   148         with self.admin_access.web_request() as req:
   146         with self.admin_access.web_request() as req:
   149             user = req.user
   147             user = req.user
   150             groupeids = [eid for eid, in req.execute('CWGroup G WHERE G name '
   148             groupeids = [eid for eid, in req.execute('CWGroup G WHERE G name '
   151                                                      'in ("managers", "users")')]
   149                                                      'in ("managers", "users")')]
   152             groups = [text_type(eid) for eid in groupeids]
   150             groups = [str(eid) for eid in groupeids]
   153             eid = text_type(user.eid)
   151             eid = str(user.eid)
   154             req.form = {
   152             req.form = {
   155                 'eid': eid, '__type:'+eid: 'CWUser',
   153                 'eid': eid, '__type:'+eid: 'CWUser',
   156                 '_cw_entity_fields:'+eid: 'login-subject,firstname-subject,surname-subject,in_group-subject',
   154                 '_cw_entity_fields:'+eid: 'login-subject,firstname-subject,surname-subject,in_group-subject',
   157                 'login-subject:'+eid:     text_type(user.login),
   155                 'login-subject:'+eid:     str(user.login),
   158                 'surname-subject:'+eid: u'Th\xe9nault',
   156                 'surname-subject:'+eid: u'Th\xe9nault',
   159                 'firstname-subject:'+eid:   u'Sylvain',
   157                 'firstname-subject:'+eid:   u'Sylvain',
   160                 'in_group-subject:'+eid:  groups,
   158                 'in_group-subject:'+eid:  groups,
   161                 }
   159                 }
   162             self.expect_redirect_handle_request(req, 'edit')
   160             self.expect_redirect_handle_request(req, 'edit')
   170     def test_user_can_change_its_password(self):
   168     def test_user_can_change_its_password(self):
   171         with self.admin_access.repo_cnx() as cnx:
   169         with self.admin_access.repo_cnx() as cnx:
   172             self.create_user(cnx, u'user')
   170             self.create_user(cnx, u'user')
   173             cnx.commit()
   171             cnx.commit()
   174         with self.new_access(u'user').web_request() as req:
   172         with self.new_access(u'user').web_request() as req:
   175             eid = text_type(req.user.eid)
   173             eid = str(req.user.eid)
   176             req.form = {
   174             req.form = {
   177                 'eid': eid, '__maineid' : eid,
   175                 'eid': eid, '__maineid' : eid,
   178                 '__type:'+eid: 'CWUser',
   176                 '__type:'+eid: 'CWUser',
   179                 '_cw_entity_fields:'+eid: 'upassword-subject',
   177                 '_cw_entity_fields:'+eid: 'upassword-subject',
   180                 'upassword-subject:'+eid: 'tournicoton',
   178                 'upassword-subject:'+eid: 'tournicoton',
   190         relations (meaning no changes)
   188         relations (meaning no changes)
   191         """
   189         """
   192         with self.admin_access.web_request() as req:
   190         with self.admin_access.web_request() as req:
   193             user = req.user
   191             user = req.user
   194             groupeids = [g.eid for g in user.in_group]
   192             groupeids = [g.eid for g in user.in_group]
   195             eid = text_type(user.eid)
   193             eid = str(user.eid)
   196             req.form = {
   194             req.form = {
   197                 'eid':       eid,
   195                 'eid':       eid,
   198                 '__type:'+eid:    'CWUser',
   196                 '__type:'+eid:    'CWUser',
   199                 '_cw_entity_fields:'+eid: 'login-subject,firstname-subject,surname-subject',
   197                 '_cw_entity_fields:'+eid: 'login-subject,firstname-subject,surname-subject',
   200                 'login-subject:'+eid:     text_type(user.login),
   198                 'login-subject:'+eid:     str(user.login),
   201                 'firstname-subject:'+eid: u'Th\xe9nault',
   199                 'firstname-subject:'+eid: u'Th\xe9nault',
   202                 'surname-subject:'+eid:   u'Sylvain',
   200                 'surname-subject:'+eid:   u'Sylvain',
   203                 }
   201                 }
   204             self.expect_redirect_handle_request(req, 'edit')
   202             self.expect_redirect_handle_request(req, 'edit')
   205             e = req.execute('Any X WHERE X eid %(x)s',
   203             e = req.execute('Any X WHERE X eid %(x)s',
   218                         '__type:X': 'CWUser',
   216                         '__type:X': 'CWUser',
   219                         '_cw_entity_fields:X': 'login-subject,upassword-subject,surname-subject,in_group-subject',
   217                         '_cw_entity_fields:X': 'login-subject,upassword-subject,surname-subject,in_group-subject',
   220                         'login-subject:X': u'adim',
   218                         'login-subject:X': u'adim',
   221                         'upassword-subject:X': u'toto', 'upassword-subject-confirm:X': u'toto',
   219                         'upassword-subject:X': u'toto', 'upassword-subject-confirm:X': u'toto',
   222                         'surname-subject:X': u'Di Mascio',
   220                         'surname-subject:X': u'Di Mascio',
   223                         'in_group-subject:X': text_type(gueid),
   221                         'in_group-subject:X': str(gueid),
   224 
   222 
   225                         '__type:Y': 'EmailAddress',
   223                         '__type:Y': 'EmailAddress',
   226                         '_cw_entity_fields:Y': 'address-subject,use_email-object',
   224                         '_cw_entity_fields:Y': 'address-subject,use_email-object',
   227                         'address-subject:Y': u'dima@logilab.fr',
   225                         'address-subject:Y': u'dima@logilab.fr',
   228                         'use_email-object:Y': 'X',
   226                         'use_email-object:Y': 'X',
   285 
   283 
   286     def test_edit_mandatory_inlined3_object(self):
   284     def test_edit_mandatory_inlined3_object(self):
   287         # non regression test for #3120495. Without the fix, leads to
   285         # non regression test for #3120495. Without the fix, leads to
   288         # "unhashable type: 'list'" error
   286         # "unhashable type: 'list'" error
   289         with self.admin_access.web_request() as req:
   287         with self.admin_access.web_request() as req:
   290             cwrelation = text_type(req.execute('CWEType X WHERE X name "CWSource"')[0][0])
   288             cwrelation = str(req.execute('CWEType X WHERE X name "CWSource"')[0][0])
   291             req.form = {'eid': [cwrelation], '__maineid' : cwrelation,
   289             req.form = {'eid': [cwrelation], '__maineid' : cwrelation,
   292 
   290 
   293                         '__type:'+cwrelation: 'CWEType',
   291                         '__type:'+cwrelation: 'CWEType',
   294                         '_cw_entity_fields:'+cwrelation: 'to_entity-object',
   292                         '_cw_entity_fields:'+cwrelation: 'to_entity-object',
   295                         'to_entity-object:'+cwrelation: [9999, 9998],
   293                         'to_entity-object:'+cwrelation: [9999, 9998],
   298                 path, _params = self.expect_redirect_handle_request(req, 'edit')
   296                 path, _params = self.expect_redirect_handle_request(req, 'edit')
   299             self.assertTrue(path.startswith('cwetype/CWSource'), path)
   297             self.assertTrue(path.startswith('cwetype/CWSource'), path)
   300 
   298 
   301     def test_edit_multiple_linked(self):
   299     def test_edit_multiple_linked(self):
   302         with self.admin_access.web_request() as req:
   300         with self.admin_access.web_request() as req:
   303             peid = text_type(self.create_user(req, u'adim').eid)
   301             peid = str(self.create_user(req, u'adim').eid)
   304             req.form = {'eid': [peid, 'Y'], '__maineid': peid,
   302             req.form = {'eid': [peid, 'Y'], '__maineid': peid,
   305 
   303 
   306                         '__type:'+peid: u'CWUser',
   304                         '__type:'+peid: u'CWUser',
   307                         '_cw_entity_fields:'+peid: u'surname-subject',
   305                         '_cw_entity_fields:'+peid: u'surname-subject',
   308                         'surname-subject:'+peid: u'Di Masci',
   306                         'surname-subject:'+peid: u'Di Masci',
   318             e = req.execute('Any P WHERE P surname "Di Masci"').get_entity(0, 0)
   316             e = req.execute('Any P WHERE P surname "Di Masci"').get_entity(0, 0)
   319             email = e.use_email[0]
   317             email = e.use_email[0]
   320             self.assertEqual(email.address, 'dima@logilab.fr')
   318             self.assertEqual(email.address, 'dima@logilab.fr')
   321 
   319 
   322         # with self.admin_access.web_request() as req:
   320         # with self.admin_access.web_request() as req:
   323             emaileid = text_type(email.eid)
   321             emaileid = str(email.eid)
   324             req.form = {'eid': [peid, emaileid],
   322             req.form = {'eid': [peid, emaileid],
   325 
   323 
   326                         '__type:'+peid: u'CWUser',
   324                         '__type:'+peid: u'CWUser',
   327                         '_cw_entity_fields:'+peid: u'surname-subject',
   325                         '_cw_entity_fields:'+peid: u'surname-subject',
   328                         'surname-subject:'+peid: u'Di Masci',
   326                         'surname-subject:'+peid: u'Di Masci',
   340         """test creation of two linked entities
   338         """test creation of two linked entities
   341         """
   339         """
   342         with self.admin_access.web_request() as req:
   340         with self.admin_access.web_request() as req:
   343             user = req.user
   341             user = req.user
   344             req.form = {'eid': 'X',
   342             req.form = {'eid': 'X',
   345                         '__cloned_eid:X': text_type(user.eid), '__type:X': 'CWUser',
   343                         '__cloned_eid:X': str(user.eid), '__type:X': 'CWUser',
   346                         '_cw_entity_fields:X': 'login-subject,upassword-subject',
   344                         '_cw_entity_fields:X': 'login-subject,upassword-subject',
   347                         'login-subject:X': u'toto',
   345                         'login-subject:X': u'toto',
   348                         'upassword-subject:X': u'toto',
   346                         'upassword-subject:X': u'toto',
   349                         }
   347                         }
   350             with self.assertRaises(ValidationError) as cm:
   348             with self.assertRaises(ValidationError) as cm:
   351                 self.ctrl_publish(req)
   349                 self.ctrl_publish(req)
   352             self.assertEqual({'upassword-subject': u'password and confirmation don\'t match'},
   350             self.assertEqual({'upassword-subject': u'password and confirmation don\'t match'},
   353                              cm.exception.errors)
   351                              cm.exception.errors)
   354             req.form = {'__cloned_eid:X': text_type(user.eid),
   352             req.form = {'__cloned_eid:X': str(user.eid),
   355                         'eid': 'X', '__type:X': 'CWUser',
   353                         'eid': 'X', '__type:X': 'CWUser',
   356                         '_cw_entity_fields:X': 'login-subject,upassword-subject',
   354                         '_cw_entity_fields:X': 'login-subject,upassword-subject',
   357                         'login-subject:X': u'toto',
   355                         'login-subject:X': u'toto',
   358                         'upassword-subject:X': u'toto',
   356                         'upassword-subject:X': u'toto',
   359                         'upassword-subject-confirm:X': u'tutu',
   357                         'upassword-subject-confirm:X': u'tutu',
   373         with self.admin_access.web_request(rollbackfirst=True) as req:
   371         with self.admin_access.web_request(rollbackfirst=True) as req:
   374             req.form = {'eid': ['X'],
   372             req.form = {'eid': ['X'],
   375                         '__type:X': 'Salesterm',
   373                         '__type:X': 'Salesterm',
   376                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   374                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   377                         'amount-subject:X': u'-10',
   375                         'amount-subject:X': u'-10',
   378                         'described_by_test-subject:X': text_type(feid),
   376                         'described_by_test-subject:X': str(feid),
   379                     }
   377                     }
   380             with self.assertRaises(ValidationError) as cm:
   378             with self.assertRaises(ValidationError) as cm:
   381                 self.ctrl_publish(req)
   379                 self.ctrl_publish(req)
   382             cm.exception.translate(text_type)
   380             cm.exception.translate(str)
   383             self.assertEqual({'amount-subject': 'value -10 must be >= 0'},
   381             self.assertEqual({'amount-subject': 'value -10 must be >= 0'},
   384                              cm.exception.errors)
   382                              cm.exception.errors)
   385 
   383 
   386         with self.admin_access.web_request(rollbackfirst=True) as req:
   384         with self.admin_access.web_request(rollbackfirst=True) as req:
   387             req.form = {'eid': ['X'],
   385             req.form = {'eid': ['X'],
   388                         '__type:X': 'Salesterm',
   386                         '__type:X': 'Salesterm',
   389                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   387                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   390                         'amount-subject:X': u'110',
   388                         'amount-subject:X': u'110',
   391                         'described_by_test-subject:X': text_type(feid),
   389                         'described_by_test-subject:X': str(feid),
   392                         }
   390                         }
   393             with self.assertRaises(ValidationError) as cm:
   391             with self.assertRaises(ValidationError) as cm:
   394                 self.ctrl_publish(req)
   392                 self.ctrl_publish(req)
   395             cm.exception.translate(text_type)
   393             cm.exception.translate(str)
   396             self.assertEqual(cm.exception.errors, {'amount-subject': 'value 110 must be <= 100'})
   394             self.assertEqual(cm.exception.errors, {'amount-subject': 'value 110 must be <= 100'})
   397 
   395 
   398         with self.admin_access.web_request(rollbackfirst=True) as req:
   396         with self.admin_access.web_request(rollbackfirst=True) as req:
   399             req.form = {'eid': ['X'],
   397             req.form = {'eid': ['X'],
   400                         '__type:X': 'Salesterm',
   398                         '__type:X': 'Salesterm',
   401                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   399                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   402                         'amount-subject:X': u'10',
   400                         'amount-subject:X': u'10',
   403                         'described_by_test-subject:X': text_type(feid),
   401                         'described_by_test-subject:X': str(feid),
   404                         }
   402                         }
   405             self.expect_redirect_handle_request(req, 'edit')
   403             self.expect_redirect_handle_request(req, 'edit')
   406             # should be redirected on the created
   404             # should be redirected on the created
   407             #eid = params['rql'].split()[-1]
   405             #eid = params['rql'].split()[-1]
   408             e = req.execute('Salesterm X').get_entity(0, 0)
   406             e = req.execute('Salesterm X').get_entity(0, 0)
   417             seid = cnx.create_entity('Salesterm', amount=0, described_by_test=feid).eid
   415             seid = cnx.create_entity('Salesterm', amount=0, described_by_test=feid).eid
   418             cnx.commit()
   416             cnx.commit()
   419 
   417 
   420         # ensure a value that violate a constraint is properly detected
   418         # ensure a value that violate a constraint is properly detected
   421         with self.admin_access.web_request(rollbackfirst=True) as req:
   419         with self.admin_access.web_request(rollbackfirst=True) as req:
   422             req.form = {'eid': [text_type(seid)],
   420             req.form = {'eid': [str(seid)],
   423                         '__type:%s'%seid: 'Salesterm',
   421                         '__type:%s'%seid: 'Salesterm',
   424                         '_cw_entity_fields:%s'%seid: 'amount-subject',
   422                         '_cw_entity_fields:%s'%seid: 'amount-subject',
   425                         'amount-subject:%s'%seid: u'-10',
   423                         'amount-subject:%s'%seid: u'-10',
   426                     }
   424                     }
   427             self.assertMultiLineEqual('''<script type="text/javascript">
   425             self.assertMultiLineEqual('''<script type="text/javascript">
   428  window.parent.handleFormValidationResponse('entityForm', null, null, [false, [%s, {"amount-subject": "value -10 must be >= 0"}], null], null);
   426  window.parent.handleFormValidationResponse('entityForm', null, null, [false, [%s, {"amount-subject": "value -10 must be >= 0"}], null], null);
   429 </script>'''%seid, self.ctrl_publish(req, 'validateform').decode('ascii'))
   427 </script>'''%seid, self.ctrl_publish(req, 'validateform').decode('ascii'))
   430 
   428 
   431         # ensure a value that comply a constraint is properly processed
   429         # ensure a value that comply a constraint is properly processed
   432         with self.admin_access.web_request(rollbackfirst=True) as req:
   430         with self.admin_access.web_request(rollbackfirst=True) as req:
   433             req.form = {'eid': [text_type(seid)],
   431             req.form = {'eid': [str(seid)],
   434                         '__type:%s'%seid: 'Salesterm',
   432                         '__type:%s'%seid: 'Salesterm',
   435                         '_cw_entity_fields:%s'%seid: 'amount-subject',
   433                         '_cw_entity_fields:%s'%seid: 'amount-subject',
   436                         'amount-subject:%s'%seid: u'20',
   434                         'amount-subject:%s'%seid: u'20',
   437                     }
   435                     }
   438             self.assertMultiLineEqual('''<script type="text/javascript">
   436             self.assertMultiLineEqual('''<script type="text/javascript">
   444         with self.admin_access.web_request(rollbackfirst=True) as req:
   442         with self.admin_access.web_request(rollbackfirst=True) as req:
   445             req.form = {'eid': ['X'],
   443             req.form = {'eid': ['X'],
   446                         '__type:X': 'Salesterm',
   444                         '__type:X': 'Salesterm',
   447                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   445                         '_cw_entity_fields:X': 'amount-subject,described_by_test-subject',
   448                         'amount-subject:X': u'0',
   446                         'amount-subject:X': u'0',
   449                         'described_by_test-subject:X': text_type(feid),
   447                         'described_by_test-subject:X': str(feid),
   450                     }
   448                     }
   451 
   449 
   452             # ensure a value that is modified in an operation on a modify
   450             # ensure a value that is modified in an operation on a modify
   453             # hook works as it should (see
   451             # hook works as it should (see
   454             # https://www.cubicweb.org/ticket/2509729 )
   452             # https://www.cubicweb.org/ticket/2509729 )
   552             self.assertEqual(params['toto'], 'tutu')
   550             self.assertEqual(params['toto'], 'tutu')
   553 
   551 
   554     def test_redirect_delete_button(self):
   552     def test_redirect_delete_button(self):
   555         with self.admin_access.web_request() as req:
   553         with self.admin_access.web_request() as req:
   556             eid = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid
   554             eid = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid
   557             req.form = {'eid': text_type(eid), '__type:%s'%eid: 'BlogEntry',
   555             req.form = {'eid': str(eid), '__type:%s'%eid: 'BlogEntry',
   558                         '__action_delete': ''}
   556                         '__action_delete': ''}
   559             path, params = self.expect_redirect_handle_request(req, 'edit')
   557             path, params = self.expect_redirect_handle_request(req, 'edit')
   560             self.assertEqual(path, 'blogentry')
   558             self.assertEqual(path, 'blogentry')
   561             self.assertIn('_cwmsgid', params)
   559             self.assertIn('_cwmsgid', params)
   562             eid = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid
   560             eid = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid
   563             req.execute('SET X use_email E WHERE E eid %(e)s, X eid %(x)s',
   561             req.execute('SET X use_email E WHERE E eid %(e)s, X eid %(x)s',
   564                         {'x': req.user.eid, 'e': eid})
   562                         {'x': req.user.eid, 'e': eid})
   565             req.cnx.commit()
   563             req.cnx.commit()
   566             req.form = {'eid': text_type(eid), '__type:%s'%eid: 'EmailAddress',
   564             req.form = {'eid': str(eid), '__type:%s'%eid: 'EmailAddress',
   567                         '__action_delete': ''}
   565                         '__action_delete': ''}
   568             path, params = self.expect_redirect_handle_request(req, 'edit')
   566             path, params = self.expect_redirect_handle_request(req, 'edit')
   569             self.assertEqual(path, 'cwuser/admin')
   567             self.assertEqual(path, 'cwuser/admin')
   570             self.assertIn('_cwmsgid', params)
   568             self.assertIn('_cwmsgid', params)
   571             eid1 = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid
   569             eid1 = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid
   572             eid2 = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid
   570             eid2 = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid
   573             req.form = {'eid': [text_type(eid1), text_type(eid2)],
   571             req.form = {'eid': [str(eid1), str(eid2)],
   574                         '__type:%s'%eid1: 'BlogEntry',
   572                         '__type:%s'%eid1: 'BlogEntry',
   575                         '__type:%s'%eid2: 'EmailAddress',
   573                         '__type:%s'%eid2: 'EmailAddress',
   576                         '__action_delete': ''}
   574                         '__action_delete': ''}
   577             path, params = self.expect_redirect_handle_request(req, 'edit')
   575             path, params = self.expect_redirect_handle_request(req, 'edit')
   578             self.assertEqual(path, 'view')
   576             self.assertEqual(path, 'view')
   670         """
   668         """
   671         with self.admin_access.web_request() as req:
   669         with self.admin_access.web_request() as req:
   672             groupeids = sorted(eid
   670             groupeids = sorted(eid
   673                                for eid, in req.execute('CWGroup G '
   671                                for eid, in req.execute('CWGroup G '
   674                                                        'WHERE G name in ("managers", "users")'))
   672                                                        'WHERE G name in ("managers", "users")'))
   675             groups = [text_type(eid) for eid in groupeids]
   673             groups = [str(eid) for eid in groupeids]
   676             cwetypeeid = req.execute('CWEType X WHERE X name "CWEType"')[0][0]
   674             cwetypeeid = req.execute('CWEType X WHERE X name "CWEType"')[0][0]
   677             basegroups = [text_type(eid)
   675             basegroups = [str(eid)
   678                           for eid, in req.execute('CWGroup G '
   676                           for eid, in req.execute('CWGroup G '
   679                                                   'WHERE X read_permission G, X eid %(x)s',
   677                                                   'WHERE X read_permission G, X eid %(x)s',
   680                                                   {'x': cwetypeeid})]
   678                                                   {'x': cwetypeeid})]
   681             cwetypeeid = text_type(cwetypeeid)
   679             cwetypeeid = str(cwetypeeid)
   682             req.form = {
   680             req.form = {
   683                 'eid':      cwetypeeid,
   681                 'eid':      cwetypeeid,
   684                 '__type:'+cwetypeeid:  'CWEType',
   682                 '__type:'+cwetypeeid:  'CWEType',
   685                 '_cw_entity_fields:'+cwetypeeid: 'name-subject,final-subject,description-subject,read_permission-subject',
   683                 '_cw_entity_fields:'+cwetypeeid: 'name-subject,final-subject,description-subject,read_permission-subject',
   686                 'name-subject:'+cwetypeeid:     u'CWEType',
   684                 'name-subject:'+cwetypeeid:     u'CWEType',