Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
e705f174
Commit
e705f174
authored
Sep 28, 1999
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
had duplicate __class_init__
parent
4f0f1ed8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
3 deletions
+98
-3
lib/python/OFS/FindSupport.py
lib/python/OFS/FindSupport.py
+98
-3
No files found.
lib/python/OFS/FindSupport.py
View file @
e705f174
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Principia Find support"""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
sys
,
os
,
string
,
time
,
Globals
,
ExtensionClass
...
...
@@ -199,8 +199,104 @@ class FindSupport(ExtensionClass.Base):
return
result
PrincipiaFind
=
ZopeFind
def
ZopeFindAndApply
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
obj_permission
=
None
,
obj_roles
=
None
,
search_sub
=
0
,
REQUEST
=
None
,
result
=
None
,
pre
=
''
,
apply_func
=
None
,
apply_path
=
''
):
"""Zope Find interface and apply"""
if
result
is
None
:
result
=
[]
if
obj_metatypes
and
'all'
in
obj_metatypes
:
obj_metatypes
=
None
if
obj_mtime
and
type
(
obj_mtime
)
==
type
(
's'
):
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
if
obj_permission
:
obj_permission
=
p_name
(
obj_permission
)
if
obj_roles
and
type
(
obj_roles
)
is
type
(
's'
):
obj_roles
=
[
obj_roles
]
if
obj_expr
:
# Setup expr machinations
md
=
td
()
if
hasattr
(
REQUEST
,
'AUTHENTICATED_USER'
):
md
.
AUTHENTICATED_USER
=
REQUEST
.
AUTHENTICATED_USER
obj_expr
=
(
Eval
(
obj_expr
,
expr_globals
),
md
,
md
.
_push
,
md
.
_pop
)
base
=
obj
if
hasattr
(
obj
,
'aq_base'
):
base
=
obj
.
aq_base
if
not
hasattr
(
base
,
'objectItems'
):
return
result
try
:
items
=
base
.
objectItems
()
except
:
return
result
try
:
add_result
=
result
.
append
except
:
raise
AttributeError
,
`result`
for
id
,
ob
in
items
:
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
dflag
=
1
if
hasattr
(
ob
,
'aq_base'
):
bs
=
ob
.
aq_base
else
:
bs
=
ob
if
(
(
not
obj_ids
or
absattr
(
bs
.
id
)
in
obj_ids
)
and
(
not
obj_metatypes
or
(
hasattr
(
bs
,
'meta_type'
)
and
bs
.
meta_type
in
obj_metatypes
))
and
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
find
(
ob
.
PrincipiaSearchSource
(),
obj_searchterm
)
>=
0
))
and
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
and
(
not
obj_mtime
or
mtime_match
(
ob
,
obj_mtime
,
obj_mspec
))
and
(
(
not
obj_permission
or
not
obj_roles
)
or
\
role_match
(
ob
,
obj_permission
,
obj_roles
)
)
):
if
apply_func
:
apply_func
(
ob
,
(
apply_path
+
'/'
+
p
))
else
:
add_result
((
p
,
ob
))
dflag
=
0
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
obj_searchterm
,
obj_expr
,
obj_mtime
,
obj_mspec
,
obj_permission
,
obj_roles
,
search_sub
,
REQUEST
,
result
,
p
,
apply_func
,
apply_path
)
if
dflag
:
ob
.
_p_deactivate
()
return
result
class
td
(
TemplateDict
,
cDocument
):
...
...
@@ -255,6 +351,7 @@ def role_match(ob, permission, roles, lt=type([]), tt=type(())):
return
1
Globals
.
default__class_init__
(
FindSupport
)
# Helper functions
...
...
@@ -267,5 +364,3 @@ def p_name(name):
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
Globals
.
default__class_init__
(
FindSupport
)
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