Commit dac1eb3f authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

more api update

parent eae23c40627a
......@@ -29,7 +29,7 @@ class MetadataTC(BaseEntityTC):
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')
......
......@@ -76,8 +76,8 @@ class WorkflowTC(CubicWebTC):
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 @@ class WorkflowTC(CubicWebTC):
[(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 @@ class WorkflowTC(CubicWebTC):
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 @@ class WorkflowTC(CubicWebTC):
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'),
......
......@@ -146,8 +146,8 @@ class Workflow(AnyEntity):
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 @@ class WorkflowableMixIn(object):
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):
......
......@@ -182,8 +182,7 @@ class CheckUniqueHook(UserIntegrityHook):
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
......
......@@ -125,13 +125,13 @@ class _SubWorkflowExitOp(hook.Operation):
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 ########################################################################
......
......@@ -363,7 +363,7 @@ def rschema_relations_values(rschema):
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment