# HG changeset patch # User Sylvain Thénault # Date 1260267162 -3600 # Node ID 6a14cff373c360fa27c540a5eacbdb63d5834bba # Parent eae23c40627adef2f256f101bdedbced3b10efaa more api update diff -r eae23c40627a -r 6a14cff373c3 entities/test/unittest_base.py --- a/entities/test/unittest_base.py Tue Dec 08 10:58:56 2009 +0100 +++ b/entities/test/unittest_base.py Tue Dec 08 11:12:42 2009 +0100 @@ -29,7 +29,7 @@ def test_creator(self): self.login(u'member') - entity = self.add_entity('Bookmark', title=u"hello", path=u'project/cubicweb') + entity = self.request().create_entity('Bookmark', title=u"hello", path=u'project/cubicweb') self.commit() self.assertEquals(entity.creator.eid, self.member.eid) self.assertEquals(entity.dc_creator(), u'member') diff -r eae23c40627a -r 6a14cff373c3 entities/test/unittest_wfobjs.py --- a/entities/test/unittest_wfobjs.py Tue Dec 08 10:58:56 2009 +0100 +++ b/entities/test/unittest_wfobjs.py Tue Dec 08 11:12:42 2009 +0100 @@ -76,8 +76,8 @@ def setup_database(self): rschema = self.schema['in_state'] - for x, y in rschema.iter_rdefs(): - self.assertEquals(rschema.rproperty(x, y, 'cardinality'), '1*') + for rdef in rschema.rdefs.values(): + self.assertEquals(rdef.cardinality, '1*') self.member = self.create_user('member') def test_workflow_base(self): @@ -210,7 +210,7 @@ [(swfstate2, state2), (swfstate3, state3)]) self.assertEquals(swftr1.destination().eid, swfstate1.eid) # workflows built, begin test - self.group = self.add_entity('CWGroup', name=u'grp1') + self.group = self.request().create_entity('CWGroup', name=u'grp1') self.commit() self.assertEquals(self.group.current_state.eid, state1.eid) self.assertEquals(self.group.current_workflow.eid, mwf.eid) @@ -295,7 +295,7 @@ twf.add_wftransition(_('close'), subwf, (released,), [(xsigned, closed), (xaborted, released)]) self.commit() - group = self.add_entity('CWGroup', name=u'grp1') + group = self.request().create_entity('CWGroup', name=u'grp1') self.commit() for trans in ('identify', 'release', 'close'): group.fire_transition(trans) @@ -320,7 +320,7 @@ twf.add_wftransition(_('release'), subwf, identified, [(xaborted, None)]) self.commit() - group = self.add_entity('CWGroup', name=u'grp1') + group = self.request().create_entity('CWGroup', name=u'grp1') self.commit() for trans, nextstate in (('identify', 'xsigning'), ('xabort', 'created'), diff -r eae23c40627a -r 6a14cff373c3 entities/wfobjs.py --- a/entities/wfobjs.py Tue Dec 08 10:58:56 2009 +0100 +++ b/entities/wfobjs.py Tue Dec 08 11:12:42 2009 +0100 @@ -146,8 +146,8 @@ requiredgroups, conditions, **kwargs) if hasattr(subworkflow, 'eid'): subworkflow = subworkflow.eid - assert _cw.req.execute('SET T subworkflow WF WHERE WF eid %(wf)s,T eid %(t)s', - {'t': tr.eid, 'wf': subworkflow}, ('wf', 't')) + assert self._cw.execute('SET T subworkflow WF WHERE WF eid %(wf)s,T eid %(t)s', + {'t': tr.eid, 'wf': subworkflow}, ('wf', 't')) for fromstate, tostate in exitpoints: tr.add_exit_point(fromstate, tostate) return tr @@ -464,9 +464,9 @@ kwargs['comment_format'] = commentformat kwargs['wf_info_for'] = self if treid is not None: - kwargs['by_transition'] = self.req.entity_from_eid(treid) + kwargs['by_transition'] = self._cw.entity_from_eid(treid) if tseid is not None: - kwargs['to_state'] = self.req.entity_from_eid(tseid) + kwargs['to_state'] = self._cw.entity_from_eid(tseid) return self._cw.create_entity('TrInfo', **kwargs) def fire_transition(self, tr, comment=None, commentformat=None): diff -r eae23c40627a -r 6a14cff373c3 hooks/integrity.py --- a/hooks/integrity.py Tue Dec 08 10:58:56 2009 +0100 +++ b/hooks/integrity.py Tue Dec 08 11:12:42 2009 +0100 @@ -182,8 +182,7 @@ entity = self.entity eschema = entity.e_schema for attr in entity.edited_attributes: - if eschema.subject_relation(attr).final and \ - eschema.has_unique_values(attr): + if eschema.subjrels[attr].final and eschema.has_unique_values(attr): val = entity[attr] if val is None: continue diff -r eae23c40627a -r 6a14cff373c3 hooks/workflow.py --- a/hooks/workflow.py Tue Dec 08 10:58:56 2009 +0100 +++ b/hooks/workflow.py Tue Dec 08 11:12:42 2009 +0100 @@ -125,13 +125,13 @@ msg %= session._(forentity.current_workflow.name) session.transaction_data[(forentity.eid, 'subwfentrytr')] = True # XXX iirk - req = forentity.req - forentity.req = session.super_session + req = forentity._cw + forentity._cw = session.super_session try: trinfo = forentity.change_state(tostate, msg, u'text/plain', tr=wftr) finally: - forentity.req = req + forentity._cw = req # hooks ######################################################################## diff -r eae23c40627a -r 6a14cff373c3 server/schemaserial.py --- a/server/schemaserial.py Tue Dec 08 10:58:56 2009 +0100 +++ b/server/schemaserial.py Tue Dec 08 11:12:42 2009 +0100 @@ -363,7 +363,7 @@ def _rdef_values(rschema, objtype, props): amap = {'order': 'ordernum'} values = {} - for prop, default in rschema.rproperty_defs(objtype).iteritems(): + for prop, default in schemamod.RelationDefinitionSchema.rproperty_defs(objtype).iteritems(): if prop in ('eid', 'constraints', 'uid', 'infered', 'permissions'): continue value = props.get(prop, default)