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

[entity 3.13 api] rename clear_all_caches into cw_clear_all_cache

parent 39437617f3f0
......@@ -165,7 +165,7 @@ class WorkflowTC(CubicWebTC):
user = self.user()
iworkflowable = user.cw_adapt_to('IWorkflowable')
iworkflowable.fire_transition('deactivate', comment=u'deactivate user')
user.clear_all_caches()
user.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'deactivated')
self._test_manager_deactivate(user)
trinfo = self._test_manager_deactivate(user)
......@@ -192,7 +192,7 @@ class WorkflowTC(CubicWebTC):
self.commit()
iworkflowable.fire_transition('wake up')
self.commit()
user.clear_all_caches()
user.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'deactivated')
# XXX test managers can change state without matching transition
......@@ -274,14 +274,14 @@ class WorkflowTC(CubicWebTC):
self.assertEqual(iworkflowable.subworkflow_input_transition(), None)
iworkflowable.fire_transition('swftr1', u'go')
self.commit()
group.clear_all_caches()
group.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_state.eid, swfstate1.eid)
self.assertEqual(iworkflowable.current_workflow.eid, swf.eid)
self.assertEqual(iworkflowable.main_workflow.eid, mwf.eid)
self.assertEqual(iworkflowable.subworkflow_input_transition().eid, swftr1.eid)
iworkflowable.fire_transition('tr1', u'go')
self.commit()
group.clear_all_caches()
group.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_state.eid, state2.eid)
self.assertEqual(iworkflowable.current_workflow.eid, mwf.eid)
self.assertEqual(iworkflowable.main_workflow.eid, mwf.eid)
......@@ -295,10 +295,10 @@ class WorkflowTC(CubicWebTC):
# force back to state1
iworkflowable.change_state('state1', u'gadget')
iworkflowable.fire_transition('swftr1', u'au')
group.clear_all_caches()
group.cw_clear_all_caches()
iworkflowable.fire_transition('tr2', u'chapeau')
self.commit()
group.clear_all_caches()
group.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_state.eid, state3.eid)
self.assertEqual(iworkflowable.current_workflow.eid, mwf.eid)
self.assertEqual(iworkflowable.main_workflow.eid, mwf.eid)
......@@ -390,7 +390,7 @@ class WorkflowTC(CubicWebTC):
):
iworkflowable.fire_transition(trans)
self.commit()
group.clear_all_caches()
group.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, nextstate)
......@@ -408,11 +408,11 @@ class CustomWorkflowTC(CubicWebTC):
wf.add_state('asleep', initial=True)
self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
{'wf': wf.eid, 'x': self.member.eid})
self.member.clear_all_caches()
self.member.cw_clear_all_caches()
iworkflowable = self.member.cw_adapt_to('IWorkflowable')
self.assertEqual(iworkflowable.state, 'activated')# no change before commit
self.commit()
self.member.clear_all_caches()
self.member.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_workflow.eid, wf.eid)
self.assertEqual(iworkflowable.state, 'asleep')
self.assertEqual(iworkflowable.workflow_history, ())
......@@ -429,7 +429,7 @@ class CustomWorkflowTC(CubicWebTC):
self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
{'wf': wf.eid, 'x': self.member.eid})
self.commit()
self.member.clear_all_caches()
self.member.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_workflow.eid, wf.eid)
self.assertEqual(iworkflowable.state, 'asleep')
self.assertEqual(parse_hist(iworkflowable.workflow_history),
......@@ -472,10 +472,10 @@ class CustomWorkflowTC(CubicWebTC):
self.commit()
self.execute('DELETE X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
{'wf': wf.eid, 'x': self.member.eid})
self.member.clear_all_caches()
self.member.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'asleep')# no change before commit
self.commit()
self.member.clear_all_caches()
self.member.cw_clear_all_caches()
self.assertEqual(iworkflowable.current_workflow.name, "default user workflow")
self.assertEqual(iworkflowable.state, 'activated')
self.assertEqual(parse_hist(iworkflowable.workflow_history),
......@@ -504,13 +504,13 @@ class AutoTransitionTC(CubicWebTC):
self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
{'wf': wf.eid, 'x': user.eid})
self.commit()
user.clear_all_caches()
user.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'asleep')
self.assertEqual([t.name for t in iworkflowable.possible_transitions()],
['rest'])
iworkflowable.fire_transition('rest')
self.commit()
user.clear_all_caches()
user.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'asleep')
self.assertEqual([t.name for t in iworkflowable.possible_transitions()],
['rest'])
......@@ -520,7 +520,7 @@ class AutoTransitionTC(CubicWebTC):
self.commit()
iworkflowable.fire_transition('rest')
self.commit()
user.clear_all_caches()
user.cw_clear_all_caches()
self.assertEqual(iworkflowable.state, 'dead')
self.assertEqual(parse_hist(iworkflowable.workflow_history),
[('asleep', 'asleep', 'rest', None),
......
......@@ -326,8 +326,8 @@ class WorkflowTransition(BaseTransition):
result[ep.subwf_state.eid] = ep.destination and ep.destination.eid
return result
def clear_all_caches(self):
super(WorkflowTransition, self).clear_all_caches()
def cw_clear_all_caches(self):
super(WorkflowTransition, self).cw_clear_all_caches()
clear_cache(self, 'exit_points')
......
......@@ -918,7 +918,7 @@ class Entity(AppObject):
assert role
self._cw_related_cache.pop('%s_%s' % (rtype, role), None)
def clear_all_caches(self): # XXX cw_clear_all_caches
def cw_clear_all_caches(self):
"""flush all caches on this entity. Further attributes/relations access
will triggers new database queries to get back values.
......@@ -991,6 +991,10 @@ class Entity(AppObject):
# deprecated stuff #########################################################
@deprecated('[3.13] use entity.cw_clear_all_caches()')
def clear_all_caches(self):
return self.cw_clear_all_caches()
@deprecated('[3.9] use entity.cw_attr_value(attr)')
def get_value(self, name):
return self.cw_attr_value(name)
......
......@@ -437,7 +437,7 @@ repository (default to 5 minutes).',
cu = session.pool[self.uri]
cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations), kwargs)
self._query_cache.clear()
entity.clear_all_caches()
entity.cw_clear_all_caches()
def delete_entity(self, session, entity):
"""delete an entity from the source"""
......@@ -453,8 +453,8 @@ repository (default to 5 minutes).',
{'x': self.eid2extid(subject, session),
'y': self.eid2extid(object, session)})
self._query_cache.clear()
session.entity_from_eid(subject).clear_all_caches()
session.entity_from_eid(object).clear_all_caches()
session.entity_from_eid(subject).cw_clear_all_caches()
session.entity_from_eid(object).cw_clear_all_caches()
def delete_relation(self, session, subject, rtype, object):
"""delete a relation from the source"""
......@@ -463,8 +463,8 @@ repository (default to 5 minutes).',
{'x': self.eid2extid(subject, session),
'y': self.eid2extid(object, session)})
self._query_cache.clear()
session.entity_from_eid(subject).clear_all_caches()
session.entity_from_eid(object).clear_all_caches()
session.entity_from_eid(subject).cw_clear_all_caches()
session.entity_from_eid(object).cw_clear_all_caches()
class RQL2RQL(object):
......
......@@ -239,7 +239,7 @@ class LDAPUserSourceTC(CubicWebTC):
iworkflowable.fire_transition('deactivate')
try:
cnx.commit()
adim.clear_all_caches()
adim.cw_clear_all_caches()
self.assertEqual(adim.in_state[0].name, 'deactivated')
trinfo = iworkflowable.latest_trinfo()
self.assertEqual(trinfo.owned_by[0].login, SYT)
......
......@@ -150,8 +150,8 @@ class UndoableTransactionTC(CubicWebTC):
txuuid = self.commit()
actions = self.cnx.transaction_info(txuuid).actions_list()
self.assertEqual(len(actions), 1)
toto.clear_all_caches()
e.clear_all_caches()
toto.cw_clear_all_caches()
e.cw_clear_all_caches()
errors = self.cnx.undo_transaction(txuuid)
undotxuuid = self.commit()
self.assertEqual(undotxuuid, None) # undo not undoable
......@@ -192,7 +192,7 @@ class UndoableTransactionTC(CubicWebTC):
self.commit()
errors = self.cnx.undo_transaction(txuuid)
self.commit()
p.clear_all_caches()
p.cw_clear_all_caches()
self.assertEqual(p.fiche[0].eid, c2.eid)
self.assertEqual(len(errors), 1)
self.assertEqual(errors[0],
......
......@@ -539,7 +539,7 @@ du :eid:`1:*ReST*`'''
self.assertEqual(person.rest_path(), 'personne/doe')
# ambiguity test
person2 = req.create_entity('Personne', prenom=u'remi', nom=u'doe')
person.clear_all_caches()
person.cw_clear_all_caches()
self.assertEqual(person.rest_path(), 'personne/eid/%s' % person.eid)
self.assertEqual(person2.rest_path(), 'personne/eid/%s' % person2.eid)
# unique attr with None value (wikiid in this case)
......
......@@ -193,7 +193,7 @@ class ImplementsSelectorTC(CubicWebTC):
class WorkflowSelectorTC(CubicWebTC):
def _commit(self):
self.commit()
self.wf_entity.clear_all_caches()
self.wf_entity.cw_clear_all_caches()
def setup_database(self):
wf = self.shell().add_workflow("wf_test", 'StateFull', default=True)
......
......@@ -165,7 +165,7 @@ class Controller(AppObject):
elif self._edited_entity:
# clear caches in case some attribute participating to the rest path
# has been modified
self._edited_entity.clear_all_caches()
self._edited_entity.cw_clear_all_caches()
path = self._edited_entity.rest_path()
else:
path = 'view'
......
......@@ -194,7 +194,7 @@ class EditControllerTC(CubicWebTC):
'use_email-object:'+emaileid: peid,
}
path, params = self.expect_redirect_publish(req, 'edit')
email.clear_all_caches()
email.cw_clear_all_caches()
self.assertEqual(email.address, 'adim@logilab.fr')
......
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