Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
erp5
Commits
f42b8d51
Commit
f42b8d51
authored
Oct 26, 2011
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Execute inode path expression and sense method with document owner.
Behaviour inspired by alarms.
parent
842bb92e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
28 deletions
+36
-28
product/ERP5/Tool/InotifyTool.py
product/ERP5/Tool/InotifyTool.py
+36
-28
No files found.
product/ERP5/Tool/InotifyTool.py
View file @
f42b8d51
...
@@ -33,6 +33,8 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
...
@@ -33,6 +33,8 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
from
Products.ERP5Type.TransactionalVariable
import
TransactionalResource
from
Products.ERP5Type.TransactionalVariable
import
TransactionalResource
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
Products.ERP5.mixin.timer_service
import
TimerServiceMixin
from
Products.ERP5.mixin.timer_service
import
TimerServiceMixin
from
AccessControl.SecurityManagement
import
newSecurityManager
,
\
getSecurityManager
,
setSecurityManager
# TODO: Current API was designed to avoid compability issues in case it is
# TODO: Current API was designed to avoid compability issues in case it is
# reimplemented using http://pypi.python.org/pypi/inotifyx
# reimplemented using http://pypi.python.org/pypi/inotifyx
...
@@ -70,36 +72,42 @@ class InotifyTool(TimerServiceMixin, BaseTool):
...
@@ -70,36 +72,42 @@ class InotifyTool(TimerServiceMixin, BaseTool):
for
x
in
self
.
objectValues
()
for
x
in
self
.
objectValues
()
if
x
.
isEnabled
()
and
current_node
in
x
.
getNodeList
()]
if
x
.
isEnabled
()
and
current_node
in
x
.
getNodeList
()]
update_state_dict
=
{}
update_state_dict
=
{}
original_security_manager
=
getSecurityManager
()
for
notify_id
in
notify_list
:
for
notify_id
in
notify_list
:
notify
=
self
.
_getOb
(
notify_id
)
notify
=
self
.
_getOb
(
notify_id
)
inode_path
=
notify
.
getInodePath
()
newSecurityManager
(
None
,
notify
.
getWrappedOwner
())
if
inode_path
:
try
:
path
=
notify
.
getPath
()
inode_path
=
notify
.
getInodePath
()
state
=
inotify_state_dict
.
get
(
path
,
{})
if
inode_path
:
new_state
=
{}
path
=
notify
.
getPath
()
for
inode_path
in
glob
.
glob
(
inode_path
):
state
=
inotify_state_dict
.
get
(
path
,
{})
for
name
in
os
.
listdir
(
inode_path
):
new_state
=
{}
p
=
os
.
path
.
join
(
inode_path
,
name
)
for
inode_path
in
glob
.
glob
(
inode_path
):
try
:
for
name
in
os
.
listdir
(
inode_path
):
s
=
os
.
lstat
(
p
)
p
=
os
.
path
.
join
(
inode_path
,
name
)
except
OSError
,
e
:
try
:
if
e
.
errno
!=
errno
.
ENOENT
:
s
=
os
.
lstat
(
p
)
raise
except
OSError
,
e
:
else
:
if
e
.
errno
!=
errno
.
ENOENT
:
new_state
[
p
]
=
s
.
st_mtime
,
s
.
st_size
raise
if
new_state
!=
state
:
else
:
update_state_dict
[
path
]
=
new_state
new_state
[
p
]
=
s
.
st_mtime
,
s
.
st_size
events
=
[{
'path'
:
p
,
'mask'
:
IN_DELETE
}
if
new_state
!=
state
:
for
p
in
set
(
state
).
difference
(
new_state
)]
update_state_dict
[
path
]
=
new_state
for
p
,
m
in
new_state
.
iteritems
():
events
=
[{
'path'
:
p
,
'mask'
:
IN_DELETE
}
if
p
in
state
:
for
p
in
set
(
state
).
difference
(
new_state
)]
if
m
==
state
[
p
]:
for
p
,
m
in
new_state
.
iteritems
():
continue
if
p
in
state
:
mask
=
IN_MODIFY
if
m
==
state
[
p
]:
else
:
continue
mask
=
IN_CREATE
mask
=
IN_MODIFY
events
.
append
({
'path'
:
p
,
'mask'
:
mask
})
else
:
getattr
(
notify
,
notify
.
getSenseMethodId
())(
events
)
mask
=
IN_CREATE
events
.
append
({
'path'
:
p
,
'mask'
:
mask
})
getattr
(
notify
,
notify
.
getSenseMethodId
())(
events
)
finally
:
setSecurityManager
(
original_security_manager
)
if
update_state_dict
:
if
update_state_dict
:
TransactionalResource
(
tpc_finish
=
lambda
txn
:
TransactionalResource
(
tpc_finish
=
lambda
txn
:
inotify_state_dict
.
update
(
update_state_dict
))
inotify_state_dict
.
update
(
update_state_dict
))
...
...
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