Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
97505b798975
Commit
35ef1f31
authored
May 02, 2011
by
Sylvain Thénault
Browse files
[entity 3.13 api] rename clear_all_caches into cw_clear_all_cache
parent
39437617f3f0
Changes
10
Hide whitespace changes
Inline
Side-by-side
entities/test/unittest_wfobjs.py
View file @
97505b79
...
...
@@ -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
),
...
...
entities/wfobjs.py
View file @
97505b79
...
...
@@ -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'
)
...
...
entity.py
View file @
97505b79
...
...
@@ -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
)
...
...
server/sources/pyrorql.py
View file @
97505b79
...
...
@@ -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
):
...
...
server/test/unittest_ldapuser.py
View file @
97505b79
...
...
@@ -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
)
...
...
server/test/unittest_undo.py
View file @
97505b79
...
...
@@ -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
],
...
...
test/unittest_entity.py
View file @
97505b79
...
...
@@ -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)
...
...
test/unittest_selectors.py
View file @
97505b79
...
...
@@ -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
)
...
...
web/controller.py
View file @
97505b79
...
...
@@ -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'
...
...
web/test/unittest_views_basecontrollers.py
View file @
97505b79
...
...
@@ -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'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment