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
cf2f95e1
Commit
cf2f95e1
authored
Dec 07, 2000
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Commit "WebDAV source" and "hookable PUT creation" features to trunk
for 2.3a1.
parent
311589c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
15 deletions
+48
-15
doc/CHANGES.txt
doc/CHANGES.txt
+8
-1
lib/python/webdav/NullResource.py
lib/python/webdav/NullResource.py
+29
-14
lib/python/webdav/hookable_PUT.py
lib/python/webdav/hookable_PUT.py
+11
-0
No files found.
doc/CHANGES.txt
View file @
cf2f95e1
...
...
@@ -41,7 +41,14 @@ Zope changes
- Implemented the "emergency user" concept, which is the new
name for what was called the superuser.
- Added new "WebDAV source view" HTTP handler, enabled by new
'-W' (note uppercase) switch to z2.py. This handler is *not*
enabled by default.
- Implemented "hookable PUT creation" (allows containers to
override webdav.NullResource's guess at the type of object
to create when PUT is done to an unknown ID).
Bugs Fixed
...
...
lib/python/webdav/NullResource.py
View file @
cf2f95e1
...
...
@@ -85,7 +85,7 @@
"""WebDAV support - null resource objects."""
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
import
sys
,
os
,
string
,
mimetypes
,
Globals
import
Acquisition
,
OFS
.
content_types
...
...
@@ -130,23 +130,38 @@ class NullResource(Persistent, Acquisition.Implicit, Resource):
# Most methods return 404 (Not Found) for null resources.
DELETE
=
OPTIONS
=
TRACE
=
PROPFIND
=
PROPPATCH
=
COPY
=
MOVE
=
HEAD
def
_default_PUT_factory
(
self
,
name
,
typ
,
body
):
# Return DTMLDoc/Image/File, based on sniffing.
from
OFS.Image
import
Image
,
File
from
OFS.DTMLDocument
import
DTMLDocument
if
typ
in
(
'text/html'
,
'text/xml'
,
'text/plain'
):
ob
=
DTMLDocument
(
''
,
__name__
=
name
)
elif
typ
[:
6
]
==
'image/'
:
ob
=
Image
(
name
,
''
,
body
,
content_type
=
typ
)
else
:
ob
=
File
(
name
,
''
,
body
,
content_type
=
typ
)
return
ob
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""Create a new non-collection resource."""
self
.
dav__init
(
REQUEST
,
RESPONSE
)
type
=
REQUEST
.
get_header
(
'content-type'
,
None
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
name
=
self
.
__name__
if
type
is
None
:
type
,
enc
=
OFS
.
content_types
.
guess_content_type
(
name
,
body
)
from
OFS.Image
import
Image
,
File
if
type
in
(
'text/html'
,
'text/xml'
,
'text/plain'
):
self
.
__parent__
.
manage_addDTMLDocument
(
name
,
''
,
body
)
elif
type
[:
6
]
==
'image/'
:
ob
=
Image
(
name
,
''
,
body
,
content_type
=
type
)
self
.
__parent__
.
_setObject
(
name
,
ob
)
else
:
ob
=
File
(
name
,
''
,
body
,
content_type
=
type
)
self
.
__parent__
.
_setObject
(
name
,
ob
)
parent
=
self
.
__parent__
body
=
REQUEST
.
get
(
'BODY'
,
''
)
typ
=
REQUEST
.
get_header
(
'content-type'
,
None
)
if
typ
is
None
:
typ
,
enc
=
OFS
.
content_types
.
guess_content_type
(
name
,
body
)
factory
=
getattr
(
parent
,
'PUT_factory'
,
self
.
_default_PUT_factory
)
ob
=
(
factory
(
name
,
typ
,
body
)
or
self
.
_default_PUT_factory
(
name
,
typ
,
body
)
)
# Delegate actual PUT handling to the new object.
ob
.
PUT
(
REQUEST
,
RESPONSE
)
self
.
__parent__
.
_setObject
(
name
,
ob
)
RESPONSE
.
setStatus
(
201
)
RESPONSE
.
setBody
(
''
)
return
RESPONSE
...
...
lib/python/webdav/hookable_PUT.py
0 → 100644
View file @
cf2f95e1
# Implement the "hookable PUT" hook.
import
re
,
OFS
.
DTMLMethod
TEXT_PATTERN
=
re
.
compile
(
'^text/.*$'
)
def
PUT_factory
(
self
,
name
,
typ
,
body
):
"""
"""
if
TEXT_PATTERN
.
match
(
typ
):
return
OFS
.
DTMLMethod
.
DTMLMethod
(
''
,
__name__
=
name
)
return
None
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