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
8fca31a6
Commit
8fca31a6
authored
Mar 10, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
82bb42ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
10 deletions
+112
-10
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+103
-5
lib/python/webdav/xmlcmds.py
lib/python/webdav/xmlcmds.py
+9
-5
No files found.
lib/python/OFS/PropertySheets.py
View file @
8fca31a6
...
...
@@ -84,10 +84,11 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
from
ZPublisher.Converters
import
type_converters
from
DocumentTemplate.DT_Util
import
html_quote
from
Globals
import
HTMLFile
,
MessageDialog
from
string
import
find
,
join
,
lower
,
split
,
rfind
from
Acquisition
import
Implicit
,
Explicit
...
...
@@ -125,6 +126,16 @@ class View(App.Management.Tabs):
self
,
script
,
path
)
psxml
=
'<d:propstat xmlns:n="%s">
\
n
'
\
' <d:prop>
\
n
'
\
'%s
\
n
'
\
' </d:prop>
\
n
'
\
' <d:status>HTTP/1.1 %s</d:status>
\
n
%s'
\
'</d:propstat>
\
n
'
class
PropertySheet
(
Persistent
,
Implicit
):
"""A PropertySheet is a container for a set of related properties and
metadata describing those properties. PropertySheets may or may not
...
...
@@ -257,7 +268,92 @@ class PropertySheet(Persistent, Implicit):
dict
[
p
[
'id'
]]
=
p
return
dict
def
dav__propstat
(
self
,
allprop
,
names
,
join
=
string
.
join
):
propstat
=
'<d:propstat xmlns:n="%s">
\
n
'
\
' <d:prop>
\
n
'
\
'%s
\
n
'
\
' </d:prop>
\
n
'
\
' <d:status>HTTP/1.1 %s</d:status>
\
n
%s'
\
'</d:propstat>
\
n
'
,
propdesc
=
' <d:responsedescription>
\
n
'
\
' %s
\
n
'
\
' </d:responsedescription>
\
n
'
def
dav__allprop
(
self
,
propstat
=
propstat
,
join
=
string
.
join
):
# DAV helper method - return one or more propstat elements
# indicating property names and values for all properties.
result
=
[]
for
item
in
self
.
propertyMap
():
name
,
type
=
item
[
'id'
],
item
.
get
(
'type'
,
'string'
)
value
=
self
.
getProperty
(
name
)
if
type
==
'tokens'
:
value
=
join
(
value
,
' '
)
elif
type
==
'lines'
:
value
=
join
(
value
,
'
\
n
'
)
# check for xml property
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
join
(
attrs
,
''
)
else
:
# Quote non-xml items here?
attrs
=
''
prop
=
' <n:%s%s>%s</n:%s>'
%
(
name
,
attrs
,
value
,
name
)
result
.
append
(
prop
)
if
not
result
:
return
''
result
=
join
(
result
,
'
\
n
'
)
return
propstat
%
(
self
.
xml_namespace
(),
result
,
'200 OK'
,
''
)
def
dav__propnames
(
self
,
propstat
=
propstat
,
join
=
string
.
join
):
# DAV helper method - return a propstat element indicating
# property names for all properties in this PropertySheet.
result
=
[]
for
name
in
self
.
propertyIds
():
result
.
append
(
' <n:%s/>'
%
name
)
if
not
result
:
return
''
result
=
join
(
result
,
'
\
n
'
)
return
propstat
%
(
self
.
xml_namespace
(),
result
,
'200 OK'
,
''
)
def
dav__propstat
(
self
,
name
,
propstat
=
propstat
,
propdesc
=
propdesc
,
join
=
string
.
join
):
# DAV helper method - return a propstat element indicating
# property name and value for the requested property.
xml_id
=
self
.
xml_namespace
()
propdict
=
self
.
_propdict
()
if
not
propdict
.
has_key
(
name
):
prop
=
' <n:%s/>'
%
name
error
=
propdesc
%
(
'The property %s does not exist.'
%
name
)
return
propstat
%
(
xml_id
,
prop
,
'404 Not Found'
,
error
))
else
:
item
=
propdict
[
name
]
name
,
type
=
item
[
'id'
],
item
.
get
(
'type'
,
'string'
)
value
=
self
.
getProperty
(
name
)
if
type
==
'tokens'
:
value
=
join
(
value
,
' '
)
elif
type
==
'lines'
:
value
=
join
(
value
,
'
\
n
'
)
# allow for xml properties
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
join
(
attrs
,
''
)
else
:
# quote non-xml items here?
attrs
=
''
prop
=
' <n:%s%s>%s</n:%s>'
%
(
name
,
attrs
,
value
,
name
)
return
propstat
%
(
xml_id
,
prop
,
'200 OK'
,
''
))
del
propstat
del
propdesc
def
olddav__propstat
(
self
,
allprop
,
names
,
join
=
string
.
join
):
# The dav__propstat method returns a chunk of xml containing
# one or more propstat elements indicating property names,
# values, errors and status codes. This is called by some
...
...
@@ -270,7 +366,8 @@ class PropertySheet(Persistent, Implicit):
' </d:prop>
\
n
'
\
' <d:status>HTTP/1.1 %%s</d:status>
\
n
%%s'
\
'</d:propstat>
\
n
'
%
self
.
xml_namespace
()
errormsg
=
' <d:responsedescription>%s</d:responsedescription>
\
n
'
errormsg
=
' <d:responsedescription>
\
n
%s
\
n
'
\
' </d:responsedescription>
\
n
'
result
=
[]
if
not
allprop
and
not
names
:
# return property names only.
...
...
@@ -408,6 +505,7 @@ class DAVProperties(Virtual, PropertySheet):
{
'id'
:
'getcontenttype'
,
'mode'
:
'r'
},
{
'id'
:
'getcontentlength'
,
'mode'
:
'r'
},
{
'id'
:
'source'
,
'mode'
:
'r'
},
{
'id'
:
'supportedlock'
,
'mode'
:
'r'
},
)
def
getProperty
(
self
,
id
,
default
=
None
):
...
...
@@ -471,8 +569,8 @@ class DAVProperties(Virtual, PropertySheet):
def
dav__supportedlock
(
self
):
return
'<d:supportedlock>
\
n
'
\
'<d:lockentry>
\
n
'
\
'<d:lockscope><d:exclusive/></d:lockscope>
\
n
'
\
'<d:locktype><d:write/></d:locktype>
\
n
'
\
#
'<d:lockscope><d:exclusive/></d:lockscope>\n' \
#
'<d:locktype><d:write/></d:locktype>\n' \
'</d:lockentry>
\
n
'
\
'</d:supportedlock>
\
n
'
...
...
lib/python/webdav/xmlcmds.py
View file @
8fca31a6
...
...
@@ -85,7 +85,7 @@
"""WebDAV xml request objects."""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
sys
,
os
,
string
from
common
import
absattr
,
aq_base
,
urlfix
...
...
@@ -144,8 +144,10 @@ class PropFind:
propsets
=
obj
.
propertysheets
.
values
()
obsheets
=
obj
.
propertysheets
else
:
propsets
=
(
DAVProps
(
obj
),)
obsheets
=
{}
davprops
=
DAVProps
(
obj
)
propsets
=
(
davprops
,)
obsheets
=
{
'DAV:'
:
davprops
}
if
self
.
allprop
:
stats
=
[]
for
ps
in
propsets
:
...
...
@@ -153,14 +155,14 @@ class PropFind:
stats
.
append
(
ps
.
dav__allprop
())
stats
=
string
.
join
(
stats
,
''
)
or
'<d:status>200 OK</d:status>
\
n
'
result
.
write
(
stats
)
elif
not
self
.
propnames
:
elif
self
.
propname
:
stats
=
[]
for
ps
in
propsets
:
if
hasattr
(
aq_base
(
ps
),
'dav__propnames'
):
stats
.
append
(
ps
.
dav__propnames
())
stats
=
string
.
join
(
stats
,
''
)
or
'<d:status>200 OK</d:status>
\
n
'
result
.
write
(
stats
)
el
se
:
el
if
self
.
propnames
:
for
name
,
ns
in
self
.
propnames
:
ps
=
obsheets
.
get
(
ns
,
None
)
if
ps
is
not
None
and
hasattr
(
aq_base
(
ps
),
'dav__propstat'
):
...
...
@@ -176,6 +178,8 @@ class PropFind:
' </d:responsedescription>
\
n
'
\
'</d:propstat>
\
n
'
%
(
ns
,
name
,
name
)
result
.
write
(
stat
)
else
:
raise
'Bad Request'
,
'Invalid request'
result
.
write
(
'</d:response>
\
n
'
)
...
...
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