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
d863acaf
Commit
d863acaf
authored
Jan 27, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #533: ZMI Find now searches in text Files.
parent
d16f0c50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+8
-1
lib/python/OFS/tests/testFileAndImage.py
lib/python/OFS/tests/testFileAndImage.py
+23
-0
No files found.
lib/python/OFS/Image.py
View file @
d863acaf
...
@@ -105,7 +105,7 @@ class File(Persistent, Implicit, PropertyManager,
...
@@ -105,7 +105,7 @@ class File(Persistent, Implicit, PropertyManager,
(
'manage_edit'
,
'manage_upload'
,
'PUT'
)),
(
'manage_edit'
,
'manage_upload'
,
'PUT'
)),
(
'View'
,
(
'View'
,
(
'index_html'
,
'view_image_or_file'
,
'get_size'
,
(
'index_html'
,
'view_image_or_file'
,
'get_size'
,
'getContentType'
,
''
)),
'getContentType'
,
'
PrincipiaSearchSource'
,
'
'
)),
(
'FTP access'
,
(
'FTP access'
,
(
'manage_FTPstat'
,
'manage_FTPget'
,
'manage_FTPlist'
)),
(
'manage_FTPstat'
,
'manage_FTPget'
,
'manage_FTPlist'
)),
(
'Delete objects'
,
(
'Delete objects'
,
...
@@ -413,6 +413,13 @@ class File(Persistent, Implicit, PropertyManager,
...
@@ -413,6 +413,13 @@ class File(Persistent, Implicit, PropertyManager,
"""
"""
raise
Redirect
,
URL1
raise
Redirect
,
URL1
def
PrincipiaSearchSource
(
self
):
""" Allow file objects to be searched.
"""
if
self
.
content_type
.
startswith
(
'text/'
):
return
str
(
self
.
data
)
return
''
# private
# private
update_data__roles__
=
()
update_data__roles__
=
()
def
update_data
(
self
,
data
,
content_type
=
None
,
size
=
None
):
def
update_data
(
self
,
data
,
content_type
=
None
,
size
=
None
):
...
...
lib/python/OFS/tests/testFileAndImage.py
View file @
d863acaf
import
Testing
import
Zope
Zope
.
startup
()
import
os
,
sys
import
os
,
sys
import
unittest
import
unittest
import
time
import
time
...
@@ -219,6 +223,25 @@ class FileTests(unittest.TestCase):
...
@@ -219,6 +223,25 @@ class FileTests(unittest.TestCase):
def
testStr
(
self
):
def
testStr
(
self
):
self
.
assertEqual
(
str
(
self
.
file
),
self
.
data
)
self
.
assertEqual
(
str
(
self
.
file
),
self
.
data
)
def
testFindSupport_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
testFindSupport_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.'
)
self
.
failUnless
(
'Party'
in
self
.
file
.
PrincipiaSearchSource
())
def
testFindFile
(
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.'
)
results
=
self
.
app
.
ZopeFind
(
self
.
app
,
obj_searchterm
=
'Party'
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
results
[
0
][
1
],
self
.
file
)
class
ImageTests
(
FileTests
):
class
ImageTests
(
FileTests
):
data
=
open
(
filedata
,
'rb'
).
read
()
data
=
open
(
filedata
,
'rb'
).
read
()
content_type
=
'image/gif'
content_type
=
'image/gif'
...
...
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