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
4c668817
Commit
4c668817
authored
Aug 14, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retire the ZMI find screens.
parent
c8e4cd5c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
682 deletions
+78
-682
CHANGES.rst
CHANGES.rst
+2
-0
src/OFS/Application.py
src/OFS/Application.py
+1
-2
src/OFS/FindSupport.py
src/OFS/FindSupport.py
+58
-85
src/OFS/Folder.py
src/OFS/Folder.py
+10
-14
src/OFS/dtml/findAdv.dtml
src/OFS/dtml/findAdv.dtml
+0
-161
src/OFS/dtml/findForm.dtml
src/OFS/dtml/findForm.dtml
+0
-105
src/OFS/dtml/findFrame.dtml
src/OFS/dtml/findFrame.dtml
+0
-19
src/OFS/dtml/findResult.dtml
src/OFS/dtml/findResult.dtml
+0
-270
src/OFS/interfaces.py
src/OFS/interfaces.py
+1
-15
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+2
-2
src/OFS/tests/testFindSupport.py
src/OFS/tests/testFindSupport.py
+4
-9
No files found.
CHANGES.rst
View file @
4c668817
...
...
@@ -28,6 +28,8 @@ Features Added
Restructuring
+++++++++++++
- Simplify ZMI control panel and globally available management screens.
- Move ZServer related testing support into ZServer.Testing.
- Split out Lifetime, webdav and ZServer packages into a ZServer project.
...
...
src/OFS/Application.py
View file @
4c668817
...
...
@@ -37,7 +37,6 @@ from zope.interface import implements
import
Folder
import
misc_
from
FindSupport
import
FindSupport
from
interfaces
import
IApplication
from
misc_
import
Misc_
...
...
@@ -51,7 +50,7 @@ LOG = getLogger('Application')
APP_MANAGER
=
None
class
Application
(
ApplicationDefaultPermissions
,
Folder
.
Folder
,
FindSupport
):
class
Application
(
ApplicationDefaultPermissions
,
Folder
.
Folder
):
"""Top-level system object"""
implements
(
IApplication
)
...
...
src/OFS/FindSupport.py
View file @
4c668817
...
...
@@ -19,8 +19,7 @@ from AccessControl import ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.Permission
import
name_trans
from
AccessControl.Permissions
import
view_management_screens
from
Acquisition
import
aq_base
from
App.special_dtml
import
DTMLFile
from
Acquisition
import
aq_base
,
aq_parent
from
DateTime.DateTime
import
DateTime
from
DocumentTemplate.DT_Util
import
Eval
from
DocumentTemplate.DT_Util
import
InstanceDict
...
...
@@ -33,33 +32,12 @@ from OFS.interfaces import IFindSupport
class
FindSupport
(
Base
):
"""Find support for Zope Folders"""
implements
(
IFindSupport
)
security
=
ClassSecurityInfo
()
#findframe is deprecated
security
.
declareProtected
(
view_management_screens
,
'manage_findFrame'
)
manage_findFrame
=
DTMLFile
(
'dtml/findFrame'
,
globals
())
security
.
declareProtected
(
view_management_screens
,
'manage_findForm'
)
manage_findForm
=
DTMLFile
(
'dtml/findForm'
,
globals
(),
management_view
=
'Find'
)
security
.
declareProtected
(
view_management_screens
,
'manage_findAdv'
)
manage_findAdv
=
DTMLFile
(
'dtml/findAdv'
,
globals
(),
management_view
=
'Find'
)
security
.
declareProtected
(
view_management_screens
,
'manage_findResult'
)
manage_findResult
=
DTMLFile
(
'dtml/findResult'
,
globals
(),
management_view
=
'Find'
)
manage_options
=
(
{
'label'
:
'Find'
,
'action'
:
'manage_findForm'
},
)
security
.
declareProtected
(
view_management_screens
,
'ZopeFind'
)
def
ZopeFind
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
...
...
@@ -68,15 +46,13 @@ class FindSupport(Base):
search_sub
=
0
,
REQUEST
=
None
,
result
=
None
,
pre
=
''
):
"""Zope Find interface"""
return
self
.
ZopeFindAndApply
(
obj
,
obj_ids
=
obj_ids
,
obj_metatypes
=
obj_metatypes
,
obj_searchterm
=
obj_searchterm
,
obj_expr
=
obj_expr
,
obj_mtime
=
obj_mtime
,
obj_mspec
=
obj_mspec
,
obj_permission
=
obj_permission
,
obj_roles
=
obj_roles
,
search_sub
=
search_sub
,
REQUEST
=
REQUEST
,
result
=
result
,
pre
=
pre
,
apply_func
=
None
,
apply_path
=
''
)
security
.
declareProtected
(
view_management_screens
,
'PrincipiaFind'
)
PrincipiaFind
=
ZopeFind
return
self
.
ZopeFindAndApply
(
obj
,
obj_ids
=
obj_ids
,
obj_metatypes
=
obj_metatypes
,
obj_searchterm
=
obj_searchterm
,
obj_expr
=
obj_expr
,
obj_mtime
=
obj_mtime
,
obj_mspec
=
obj_mspec
,
obj_permission
=
obj_permission
,
obj_roles
=
obj_roles
,
search_sub
=
search_sub
,
REQUEST
=
REQUEST
,
result
=
result
,
pre
=
pre
,
apply_func
=
None
,
apply_path
=
''
)
security
.
declareProtected
(
view_management_screens
,
'ZopeFindAndApply'
)
def
ZopeFindAndApply
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
...
...
@@ -89,72 +65,69 @@ class FindSupport(Base):
"""Zope Find interface and apply"""
if
result
is
None
:
result
=
[]
result
=
[]
if
obj_metatypes
and
'all'
in
obj_metatypes
:
obj_metatypes
=
None
obj_metatypes
=
None
if
obj_mtime
and
type
(
obj_mtime
)
==
type
(
's'
):
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
if
obj_mtime
and
isinstance
(
obj_mtime
,
str
):
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
if
obj_permission
:
obj_permission
=
p_name
(
obj_permission
)
obj_permission
=
p_name
(
obj_permission
)
if
obj_roles
and
type
(
obj_roles
)
is
type
(
's'
):
obj_roles
=
[
obj_roles
]
if
obj_roles
and
isinstance
(
obj_roles
,
str
):
obj_roles
=
[
obj_roles
]
if
obj_expr
:
# Setup expr machinations
md
=
td
()
obj_expr
=
(
Eval
(
obj_expr
),
md
,
md
.
_push
,
md
.
_pop
)
md
=
td
()
obj_expr
=
(
Eval
(
obj_expr
),
md
,
md
.
_push
,
md
.
_pop
)
base
=
aq_base
(
obj
)
if
not
hasattr
(
base
,
'objectItems'
):
return
result
try
:
items
=
obj
.
objectItems
()
except
:
return
result
try
:
items
=
obj
.
objectItems
()
except
Exception
:
return
result
try
:
add_result
=
result
.
append
except
:
raise
AttributeError
,
`result`
try
:
add_result
=
result
.
append
except
Exception
:
raise
AttributeError
(
repr
(
result
))
for
id
,
ob
in
items
:
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
dflag
=
1
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
is
None
):
dflag
=
1
bs
=
aq_base
(
ob
)
if
(
(
not
obj_ids
or
absattr
(
bs
.
getId
())
in
obj_ids
)
and
if
((
not
obj_ids
or
absattr
(
bs
.
getId
())
in
obj_ids
)
and
(
not
obj_metatypes
or
(
hasattr
(
bs
,
'meta_type'
)
and
bs
.
meta_type
in
obj_metatypes
))
and
bs
.
meta_type
in
obj_metatypes
))
and
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
obj_searchterm
in
ob
.
PrincipiaSearchSource
())
or
obj_searchterm
in
ob
.
PrincipiaSearchSource
())
or
(
hasattr
(
ob
,
'SearchableText'
)
and
obj_searchterm
in
ob
.
SearchableText
())
)
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
)
)
):
)
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
))
apply_func
(
ob
,
(
apply_path
+
'/'
+
p
))
else
:
add_result
((
p
,
ob
))
dflag
=
0
dflag
=
0
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
...
...
@@ -164,7 +137,8 @@ class FindSupport(Base):
search_sub
,
REQUEST
,
result
,
p
,
apply_func
,
apply_path
)
if
dflag
:
ob
.
_p_deactivate
()
if
dflag
:
ob
.
_p_deactivate
()
return
result
...
...
@@ -176,32 +150,32 @@ class td(RestrictedDTML, TemplateDict):
def
expr_match
(
ob
,
ed
,
c
=
InstanceDict
,
r
=
0
):
e
,
md
,
push
,
pop
=
ed
e
,
md
,
push
,
pop
=
ed
push
(
c
(
ob
,
md
))
try
:
r
=
e
.
eval
(
md
)
try
:
r
=
e
.
eval
(
md
)
finally
:
pop
()
return
r
def
mtime_match
(
ob
,
t
,
q
,
fn
=
hasattr
):
if
not
fn
(
ob
,
'_p_mtime'
):
return
0
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
def
role_match
(
ob
,
permission
,
roles
,
lt
=
type
([]),
tt
=
type
(())):
pr
=
[]
fn
=
pr
.
append
pr
=
[]
fn
=
pr
.
append
while
1
:
if
hasattr
(
ob
,
permission
):
p
=
getattr
(
ob
,
permission
)
p
=
getattr
(
ob
,
permission
)
if
type
(
p
)
is
lt
:
map
(
fn
,
p
)
if
hasattr
(
ob
,
'
aq_parent
'
):
ob
=
ob
.
aq_parent
if
hasattr
(
ob
,
'
__parent__
'
):
ob
=
aq_parent
(
ob
)
continue
break
if
type
(
p
)
is
tt
:
...
...
@@ -211,8 +185,8 @@ def role_match(ob, permission, roles, lt=type([]), tt=type(())):
map
(
fn
,
(
'Manager'
,
'Anonymous'
))
break
if
hasattr
(
ob
,
'
aq_parent
'
):
ob
=
ob
.
aq_parent
if
hasattr
(
ob
,
'
__parent__
'
):
ob
=
aq_parent
(
ob
)
continue
break
...
...
@@ -222,10 +196,9 @@ def role_match(ob, permission, roles, lt=type([]), tt=type(())):
return
1
# Helper functions
def
absattr
(
attr
):
if
callable
(
attr
):
return
attr
()
if
callable
(
attr
):
return
attr
()
return
attr
...
...
src/OFS/Folder.py
View file @
4c668817
...
...
@@ -20,7 +20,6 @@ from App.special_dtml import DTMLFile
from
zope.interface
import
implements
from
OFS
import
bbb
from
OFS.FindSupport
import
FindSupport
from
OFS.interfaces
import
IFolder
from
OFS.Lockable
import
LockableItem
from
OFS.ObjectManager
import
ObjectManager
...
...
@@ -52,14 +51,12 @@ def manage_addFolder(self, id, title='',
class
Folder
(
ObjectManager
,
PropertyManager
,
RoleManager
,
Collection
,
LockableItem
,
Item
,
FindSupport
,
):
ObjectManager
,
PropertyManager
,
RoleManager
,
Collection
,
LockableItem
,
Item
):
"""Folders are basic container objects that provide a standard
interface for object management. Folder objects also implement
...
...
@@ -71,16 +68,15 @@ class Folder(
_properties
=
({
'id'
:
'title'
,
'type'
:
'string'
,
'mode'
:
'wd'
},)
manage_options
=
(
manage_options
=
(
ObjectManager
.
manage_options
+
({
'label'
:
'View'
,
'action'
:
''
},
)
+
PropertyManager
.
manage_options
+
RoleManager
.
manage_options
+
Item
.
manage_options
+
FindSupport
.
manage_options
)
Item
.
manage_options
)
__ac_permissions__
=
()
__ac_permissions__
=
()
def
__init__
(
self
,
id
=
None
):
if
id
is
not
None
:
...
...
src/OFS/dtml/findAdv.dtml
deleted
100644 → 0
View file @
c8e4cd5c
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<FORM ACTION="manage_findResult" METHOD="GET">
<INPUT TYPE = "hidden" NAME="searchtype" VALUE="advanced">
<TABLE>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Find objects of type:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_metatypes:list" SIZE="8" MULTIPLE>
<OPTION VALUE="all" SELECTED> All types
<dtml-in all_meta_types mapping>
<OPTION VALUE="&dtml-name;"> &dtml-name;
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
with ids:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_ids:tokens" SIZE="30">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
containing:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_searchterm" SIZE="30">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
expr:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<TEXTAREA NAME="obj_expr" ROWS="4" COLS="30"></TEXTAREA>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
modified:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_mspec">
<OPTION VALUE="<"> before
<OPTION VALUE=">"> after
</SELECT>
</div>
<INPUT TYPE="TEXT" NAME="obj_mtime" SIZE="22">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
where the roles:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_roles:list" SIZE="3" MULTIPLE>
<dtml-in valid_roles>
<OPTION VALUE="&dtml-sequence-item;"> &dtml-sequence-item;
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
have permission:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_permission">
<dtml-in permission_settings mapping>
<OPTION VALUE="&dtml-name;"> &dtml-name;
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Sort results by:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="skey">
<OPTION VALUE="meta_type">Type
<OPTION VALUE="id">Id
</SELECT>
<INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse">
<span class="form-label"> Reverse?</span>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-text">
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="0">
Search only in this folder
<BR>
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="1" CHECKED>
Search all subfolders
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<INPUT class="form-element" TYPE="SUBMIT" NAME="btn_submit" VALUE="Find">
<span class="form-text">
<a href="manage_findForm"> Simple...<a>
</span>
</div>
</TD>
</TR>
</TABLE>
</FORM>
<dtml-var manage_page_footer>
src/OFS/dtml/findForm.dtml
deleted
100644 → 0
View file @
c8e4cd5c
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<p class="form-help">
Find allows you to locate Zope objects based on different
criteria. For more find choices choose the <EM>Advanced</EM>
find option.
</p>
<FORM ACTION="manage_findResult" METHOD="GET">
<INPUT TYPE = "hidden" NAME="searchtype" VALUE="simple">
<TABLE class="action">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Find objects of type:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_metatypes:list" SIZE="8" MULTIPLE>
<OPTION VALUE="all" SELECTED> All types
<dtml-let sorted_meta_types="[]">
<dtml-in all_meta_types mapping>
<dtml-call "sorted_meta_types.append(name)">
</dtml-in>
<dtml-call "sorted_meta_types.sort()">
<dtml-in sorted_meta_types>
<OPTION VALUE="&dtml-sequence-item;">&dtml-sequence-item;
</dtml-in>
</dtml-let>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
with ids:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_ids:tokens" SIZE="30">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
containing:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_searchterm" SIZE="30">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
modified:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_mspec">
<OPTION VALUE="<"> before
<OPTION VALUE=">"> after
</SELECT>
</div>
<INPUT TYPE="TEXT" NAME="obj_mtime" SIZE="22">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-text">
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="0">
Search only in this folder
<BR>
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="1" CHECKED>
Search all subfolders
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<INPUT class="form-element" TYPE="SUBMIT" NAME="btn_submit" VALUE="Find">
<span class="form-text">
<a href="manage_findAdv">Advanced...<a>
</span>
</div>
</TD>
</TR>
</TABLE>
</FORM>
<dtml-var manage_page_footer>
src/OFS/dtml/findFrame.dtml
deleted
100644 → 0
View file @
c8e4cd5c
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML
lang=
"en"
>
<HEAD>
<TITLE>
Find
</TITLE>
</HEAD>
<FRAMESET
ROWS=
"52%,*"
>
<dtml-if
cv_ffaf
>
<FRAME
SRC=
"<dtml-var "
REQUEST
.
URL1
"
html_quote
>
/manage_findAdv" NAME="findForm"
<dtml-else>
<FRAME
SRC=
"<dtml-var "
REQUEST
.
URL1
"
html_quote
>
/manage_findForm" NAME="findForm"
</dtml-if>
MARGINWIDTH="2" MARGINHEIGHT="2" SCROLLING="auto">
<FRAME
SRC=
"<dtml-var "
REQUEST
.
URL1
"
html_quote
>
/manage_findResult" NAME="findResult"
MARGINWIDTH="2" MARGINHEIGHT="0" SCROLLING="auto">
</FRAMESET>
<NOFRAMES>
Management interfaces require the use of a
<B>
frames-capable
</B>
web browser.
</NOFRAMES>
</HTML>
src/OFS/dtml/findResult.dtml
deleted
100644 → 0
View file @
c8e4cd5c
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<dtml-in expr="('obj_ids', 'obj_metatypes', 'obj_searchterm', 'obj_expr', 'obj_mtime', 'obj_mspec', 'obj_permission', 'obj_roles', 'search_sub')">
<dtml-else expr="_.hasattr(REQUEST, _['sequence-item'])">
<dtml-call expr="REQUEST.set(_['sequence-item'], _.None)">
</dtml-else>
</dtml-in>
<dtml-if btn_submit>
<dtml-with "_.namespace(
results=PrincipiaFind(this(),
obj_ids=obj_ids,
obj_metatypes=obj_metatypes,
obj_searchterm=obj_searchterm,
obj_expr=obj_expr,
obj_mtime=obj_mtime,
obj_mspec=obj_mspec,
obj_permission=obj_permission,
obj_roles=obj_roles,
search_sub=search_sub,
REQUEST=REQUEST))">
<dtml-unless batch_size>
<dtml-call "REQUEST.set('batch_size',20)">
</dtml-unless>
<dtml-if results>
<p class="std-text">
Displaying items
<dtml-in name="results" size=batch_size start=query_start>
<dtml-if sequence-start>&dtml-sequence-number;</dtml-if><dtml-if
sequence-end>-&dtml-sequence-number; of <dtml-var
"_.len(results)"></dtml-if></dtml-in> items matching your query. You can
<a href="#form">revise</a> your search terms below.
</p>
<dtml-else>
<p class="std-text">
No items were found matching your query. You can <a href="#form">revise</a>
your search terms below.
</p>
</dtml-if>
<dtml-unless searchtype>
<dtml-call expr="REQUEST.set('searchtype', 'simple')">
</dtml-unless>
<dtml-unless skey>
<dtml-call expr="REQUEST.set('skey', 'id')">
</dtml-unless>
<dtml-unless rkey>
<dtml-call expr="REQUEST.set('rkey', '')">
</dtml-unless>
<dtml-if "rkey == 'reverse'">
<dtml-call "REQUEST.set('rkey', skey)">
</dtml-if>
<TABLE width="100%" CELLSPACING="0" CELLPADDING="2" border="0">
<dtml-if expr="_.len(results) > batch_size">
<tr class="list-header">
<td width="50%">
<div class="list-item">
<dtml-in name="results" previous size="batch_size" start="query_start">
<strong> <a href="<dtml-var "REQUEST.URL" html_quote>&dtml-sequence-query;query_start=&dtml-previous-sequence-start-number;">< Previous</a></strong>
<dtml-else> </dtml-in></div>
</td>
<td align="right" width="50%">
<div class="list-item">
<dtml-in name="results" next size=batch_size start=query_start>
<strong><a href="<dtml-var "REQUEST.URL" html_quote>&dtml-sequence-query;query_start=&dtml-next-sequence-start-number;">Next ></a></strong>
<dtml-else> </dtml-in></div>
</td>
</tr>
</dtml-if>
</table>
<TABLE width="100%" CELLSPACING="0" CELLPADDING="2" border="0">
<dtml-in results size="batch_size" start="query_start" sort_expr="skey" reverse_expr="rkey">
<dtml-if sequence-odd>
<TR class="row-normal">
<dtml-else>
<TR class="row-hilite">
</dtml-if>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16"></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="list-item">
<A HREF="&dtml.url_quote-sequence-key;/manage_workspace">
&dtml-sequence-key;
<dtml-if title>
(&dtml-title;)
</dtml-if>
</A>
</div>
</TD>
</TR>
</dtml-in>
</TABLE>
</dtml-with>
</dtml-if>
<a name="form">
<FORM ACTION="manage_findResult" METHOD="GET">
<TABLE class="action">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Find objects of type:</a>
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_metatypes:list" SIZE="4" MULTIPLE>
<OPTION VALUE="all" <dtml-in obj_metatypes><dtml-if "_['sequence-item'] == 'all'">SELECTED</dtml-if></dtml-in>> All types
<dtml-in all_meta_types mapping>
<OPTION VALUE="&dtml-name;" <dtml-in obj_metatypes><dtml-if "_['sequence-item'] == _['name']">SELECTED</dtml-if></dtml-in>>&dtml-name;
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
with ids:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_ids:tokens" SIZE="30" VALUE="<dtml-var "' '.join(obj_ids or [])">">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
containing:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="obj_searchterm" SIZE="30" VALUE="<dtml-var "REQUEST.obj_searchterm" html_quote>">
</TD>
</TR>
<dtml-if "searchtype == 'advanced'">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
expr:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<TEXTAREA NAME="obj_expr" ROWS="4" COLS="30">&dtml-obj_expr;</TEXTAREA>
</TD>
</TR>
</dtml-if>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
modified:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_mspec">
<OPTION VALUE="<" <dtml-if "REQUEST.obj_mspec == '<'">SELECTED</dtml-if>> before
<OPTION VALUE=">" <dtml-if "REQUEST.obj_mspec == '>'">SELECTED</dtml-if>> after
</SELECT>
</div>
<INPUT TYPE="TEXT" NAME="obj_mtime" SIZE="22" VALUE="&dtml-obj_mtime;">
</TD>
</TR>
<dtml-if "searchtype == 'advanced'">
<INPUT TYPE = "hidden" NAME="searchtype" VALUE="advanced">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
where the roles:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_roles:list" SIZE="3" MULTIPLE>
<dtml-in valid_roles>
<dtml-if obj_roles>
<OPTION VALUE="&dtml-sequence-item;"<dtml-if "_['sequence-item'] in obj_roles">SELECTED</dtml-if>>&dtml-sequence-item;
<dtml-else>
<OPTION VALUE="&dtml-sequence-item;">&dtml-sequence-item;
</dtml-if>
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
have permission:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="obj_permission">
<dtml-in permission_settings mapping>
<OPTION VALUE="&dtml-name;"<dtml-in obj_metatypes><dtml-if "_['sequence-item'] == _['name']">SELECTED</dtml-if></dtml-in>> &dtml-name;
</dtml-in>
</SELECT>
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Sort results by:
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<SELECT NAME="skey">
<OPTION VALUE="id">Id
<OPTION VALUE="meta_type">Type
</SELECT>
<span class="form-label">
<INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse"> Reverse?
</span>
</div>
</TD>
</TR>
</dtml-if>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-text">
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="0" <dtml-if "REQUEST.search_sub == 0">CHECKED</dtml-if>>
Search only in this folder
<BR>
<INPUT TYPE="RADIO" NAME="search_sub:int" VALUE="1" <dtml-if "REQUEST.search_sub == 1">CHECKED</dtml-if>>
Search all subfolders
</div>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-element">
<INPUT TYPE="SUBMIT" NAME="btn_submit" VALUE="Find">
<span class="form-text">
<dtml-if "searchtype == 'advanced'">
<a href="manage_findForm">Simple...<a>
<dtml-else>
<a href="manage_findAdv">Advanced...<a>
</dtml-if>
</span>
</div>
</TD>
</TR>
</TABLE>
</FORM>
<dtml-var manage_page_footer>
src/OFS/interfaces.py
View file @
4c668817
...
...
@@ -774,18 +774,9 @@ class IObjectManager(IZopeObject, ICopyContainer, INavigation, IManageable,
"""
# XXX: might contain non-API methods and outdated comments;
# not synced with ZopeBook API Reference;
# based on OFS.FindSupport.FindSupport
class
IFindSupport
(
Interface
):
"""Find support for Zope Folders"""
manage_findFrame
=
Attribute
(
""" """
)
manage_findForm
=
Attribute
(
""" """
)
manage_findAdv
=
Attribute
(
""" """
)
manage_findResult
=
Attribute
(
""" """
)
def
ZopeFind
(
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
...
...
@@ -794,8 +785,6 @@ class IFindSupport(Interface):
REQUEST
=
None
,
result
=
None
,
pre
=
''
):
"""Zope Find interface"""
PrincipiaFind
=
ZopeFind
def
ZopeFindAndApply
(
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
...
...
@@ -1004,10 +993,7 @@ class IPropertyManager(Interface):
"""Delete one or more properties specified by 'ids'."""
# XXX: based on OFS.Folder.Folder
class
IFolder
(
IObjectManager
,
IPropertyManager
,
IRoleManager
,
IItem
,
IFindSupport
):
class
IFolder
(
IObjectManager
,
IPropertyManager
,
IRoleManager
,
IItem
):
"""Folders are basic container objects that provide a standard
interface for object management. Folder objects also implement a
management interface and can have arbitrary properties.
...
...
src/OFS/tests/testFileAndImage.py
View file @
4c668817
...
...
@@ -291,12 +291,12 @@ class FileTests(unittest.TestCase):
def
testStr
(
self
):
self
.
assertEqual
(
str
(
self
.
file
),
self
.
data
)
def
test
FindSupport
_not_text
(
self
):
def
test
PrincipiaSearchSource
_not_text
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'application/octet-stream'
,
filedata
=
''
.
join
([
chr
(
x
)
for
x
in
range
(
256
)]))
self
.
assertEqual
(
self
.
file
.
PrincipiaSearchSource
(),
''
)
def
test
FindSupport
_text
(
self
):
def
test
PrincipiaSearchSource
_text
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'Now is the time for all good men to '
'come to the aid of the Party.'
)
...
...
src/OFS/tests/testFindSupport.py
View file @
4c668817
...
...
@@ -22,9 +22,9 @@ class TestFindSupport(unittest.TestCase):
def
setUp
(
self
):
self
.
base
=
DummyFolder
(
'base'
)
self
.
base
[
'1'
]
=
DummyItem
(
'1'
)
self
.
base
[
'2'
]
=
DummyItem
(
'2'
)
self
.
base
[
'3'
]
=
DummyItem
(
'3'
)
self
.
base
[
'1'
]
=
DummyItem
(
'1'
)
self
.
base
[
'2'
]
=
DummyItem
(
'2'
)
self
.
base
[
'3'
]
=
DummyItem
(
'3'
)
def
test_interfaces
(
self
):
from
OFS.interfaces
import
IFindSupport
...
...
@@ -38,7 +38,7 @@ class TestFindSupport(unittest.TestCase):
def
test_find_apply
(
self
):
def
func
(
obj
,
p
):
obj
.
id
=
'foo'
+
obj
.
id
obj
.
id
=
'foo'
+
obj
.
id
# ZopeFindAndApply does not return anything
# but applies a function to the objects found
self
.
assertFalse
(
self
.
base
.
ZopeFindAndApply
(
...
...
@@ -47,8 +47,3 @@ class TestFindSupport(unittest.TestCase):
self
.
assertEqual
(
self
.
base
[
'1'
].
id
,
'1'
)
self
.
assertEqual
(
self
.
base
[
'2'
].
id
,
'foo2'
)
self
.
assertEqual
(
self
.
base
[
'3'
].
id
,
'3'
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
TestFindSupport
),
))
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