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
909e3c1c
Commit
909e3c1c
authored
May 17, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wrapper checking to property mutator methods available from dtml.
parent
d08be178
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+12
-4
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+16
-6
No files found.
lib/python/OFS/PropertyManager.py
View file @
909e3c1c
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property management"""
__version__
=
'$Revision: 1.2
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
import
ExtensionClass
,
Globals
import
ZDOM
...
...
@@ -288,10 +288,15 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
# Web interface
def
_wrapperCheck
(
self
,
object
):
if
hasattr
(
object
,
'aq_base'
):
raise
ValueError
,
'Invalid property value: wrapped object'
def
manage_addProperty
(
self
,
id
,
value
,
type
,
REQUEST
=
None
):
"""Add a new property via the web. Sets a new property with
the given id, type, and value."""
self
.
_wrapperCheck
(
value
)
if
type_converters
.
has_key
(
type
):
value
=
type_converters
[
type
](
value
)
self
.
_setProperty
(
id
,
value
,
type
)
...
...
@@ -300,9 +305,11 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
def
manage_editProperties
(
self
,
REQUEST
):
"""Edit object properties via the web."""
for
p
in
self
.
_properties
:
n
=
p
[
'id'
]
self
.
_setPropValue
(
n
,
REQUEST
.
get
(
n
,
''
))
for
prop
in
self
.
_properties
:
name
=
prop
[
'id'
]
value
=
REQUEST
.
get
(
name
,
''
)
self
.
_wrapperCheck
(
value
)
self
.
_setPropValue
(
name
,
value
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
@@ -328,6 +335,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
if
self
.
hasProperty
(
name
):
if
not
'w'
in
propdict
[
name
].
get
(
'mode'
,
'wd'
):
raise
'BadRequest'
,
'%s cannot be changed'
%
name
self
.
_wrapperCheck
(
value
)
self
.
_setPropValue
(
name
,
value
)
if
REQUEST
is
not
None
:
...
...
lib/python/OFS/PropertySheets.py
View file @
909e3c1c
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
4
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
,
Globals
from
ZPublisher.Converters
import
type_converters
...
...
@@ -395,7 +395,15 @@ class PropertySheet(Persistent, Implicit):
def
manage_propertiesForm
(
self
,
URL1
):
" "
raise
'Redirect'
,
URL1
+
'/manage'
def
_wrapperCheck
(
self
,
object
):
# Raise an error if object appears to be wrapped. If a
# PropertySheet implementation ever needs to store wrapped
# objects for some reason, it will need to override this
# method.
if
hasattr
(
object
,
'aq_base'
):
raise
ValueError
,
'Invalid property value: wrapped object'
def
manage_addProperty
(
self
,
id
,
value
,
type
,
REQUEST
=
None
):
"""Add a new property via the web. Sets a new property with
the given id, type, and value."""
...
...
@@ -417,6 +425,7 @@ class PropertySheet(Persistent, Implicit):
propdict
=
self
.
_propdict
()
for
name
,
value
in
props
.
items
():
if
self
.
hasProperty
(
name
):
self
.
_wrapperCheck
(
value
)
self
.
_updateProperty
(
name
,
value
)
if
REQUEST
is
not
None
:
return
MessageDialog
(
...
...
@@ -426,10 +435,11 @@ class PropertySheet(Persistent, Implicit):
def
manage_editProperties
(
self
,
REQUEST
):
"""Edit object properties via the web."""
for
p
in
self
.
propertyMap
():
n
=
p
[
'id'
]
self
.
_updateProperty
(
n
,
REQUEST
.
get
(
n
,
''
))
for
prop
in
self
.
propertyMap
():
name
=
prop
[
'id'
]
value
=
REQUEST
.
get
(
name
,
''
)
self
.
_wrapperCheck
(
value
)
self
.
_updateProperty
(
name
,
value
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
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