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
cubes
email
Commits
c0126bae8ceb
Commit
975e7835
authored
Oct 07, 2009
by
Sylvain Thénault
Browse files
3.5 api
parent
362a3f275a27
Changes
1
Hide whitespace changes
Inline
Side-by-side
hooks.py
View file @
c0126bae
...
...
@@ -17,7 +17,7 @@ from logilab.mtconverter import TransformError
from
cubicweb
import
UnknownEid
from
cubicweb.server.pool
import
PreCommitOperation
from
cubicweb.server.hooksmanager
import
Hook
from
cubicweb.
sobjects.notification
import
parse_message_id
from
cubicweb.
common.mail
import
parse_message_id
def
fix_ownership
(
session
,
eid
,
email
):
...
...
@@ -90,10 +90,10 @@ class ExtractEmailChangeState(PreCommitOperation):
if
not
hasattr
(
entity
,
'in_state'
):
self
.
error
(
'bad change state instruction for eid %s'
,
eid
)
continue
tr
ansition
=
entity
.
can_pass_
transition
(
trname
)
if
tran
sition
:
tr
=
entity
.
current_workflow
and
entity
.
current_workflow
.
transition
_by_name
(
trname
)
if
tr
an
d
tr
.
may_be_fired
(
entity
.
eid
)
:
try
:
self
.
change_state
(
entity
,
tr
ansition
)
self
.
change_state
(
entity
,
tr
)
except
:
self
.
exception
(
'while changing state off %s from email %s'
,
entity
,
self
.
email
)
...
...
@@ -102,8 +102,7 @@ class ExtractEmailChangeState(PreCommitOperation):
trname
,
entity
)
def
change_state
(
self
,
entity
,
transition
):
entity
.
change_state
(
transition
.
destination_state
[
0
].
eid
)
trinfo
=
entity
.
latest_trinfo
()
trinfo
=
entity
.
fire_transition
(
transition
)
self
.
session
.
execute
(
'SET X generated_by S WHERE X eid %(x)s, S eid %(s)s'
,
{
'x'
:
trinfo
.
eid
,
's'
:
self
.
email
.
eid
},
'x'
)
fix_ownership
(
self
.
session
,
trinfo
.
eid
,
self
.
email
)
...
...
Write
Preview
Markdown
is supported
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