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
8c4be9f6
Commit
8c4be9f6
authored
May 26, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wrapper checking to property management code.
parent
afb3a08c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+15
-3
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+9
-1
No files found.
lib/python/OFS/PropertyManager.py
View file @
8c4be9f6
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property management"""
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
5
$'
[
11
:
-
2
]
import
ExtensionClass
,
Globals
import
ZDOM
...
...
@@ -214,13 +214,24 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
return
md
.
get
(
'type'
,
'string'
)
return
None
def
_setPropValue
(
self
,
id
,
value
):
setattr
(
self
,
id
,
value
)
def
_delPropValue
(
self
,
id
):
delattr
(
self
,
id
)
def
_wrapperCheck
(
self
,
object
):
# Raise an error if an object is wrapped.
if
hasattr
(
object
,
'aq_base'
):
raise
ValueError
,
'Invalid property value: wrapped object'
return
def
_setPropValue
(
self
,
id
,
value
):
self
.
_wrapperCheck
(
value
)
setattr
(
self
,
id
,
value
)
def
_delPropValue
(
self
,
id
):
delattr
(
self
,
id
)
def
_setProperty
(
self
,
id
,
value
,
type
=
'string'
):
# for selection and multiple selection properties
# the value argument indicates the select variable
# of the property
self
.
_wrapperCheck
(
value
)
if
not
self
.
valid_property_id
(
id
):
raise
'Bad Request'
,
'Invalid or duplicate property id'
if
type
in
(
'selection'
,
'multiple selection'
):
...
...
@@ -240,6 +251,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
# Update the value of an existing property. If value
# is a string, an attempt will be made to convert
# the value to the type of the existing property.
self
.
_wrapperCheck
(
value
)
if
not
self
.
hasProperty
(
id
):
raise
'Bad Request'
,
'The property %s does not exist'
%
id
if
type
(
value
)
==
type
(
''
):
...
...
lib/python/OFS/PropertySheets.py
View file @
8c4be9f6
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.4
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
7
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
,
Globals
from
ZPublisher.Converters
import
type_converters
...
...
@@ -197,10 +197,17 @@ class PropertySheet(Persistent, Implicit):
return
getattr
(
self
.
v_self
(),
id
)
return
default
def
_wrapperCheck
(
self
,
object
):
# Raise an error if an object is wrapped.
if
hasattr
(
object
,
'aq_base'
):
raise
ValueError
,
'Invalid property value: wrapped object'
return
def
_setProperty
(
self
,
id
,
value
,
type
=
'string'
,
meta
=
None
):
# Set a new property with the given id, value and optional type.
# Note that different property sets may support different typing
# systems.
self
.
_wrapperCheck
(
value
)
if
not
self
.
valid_property_id
(
id
):
raise
'Bad Request'
,
'Invalid property id, %s.'
%
id
if
not
self
.
property_extensible_schema__
():
...
...
@@ -230,6 +237,7 @@ class PropertySheet(Persistent, Implicit):
# an attempt will be made to convert the value to the type of the
# existing property. If a mapping containing meta-data is passed,
# it will used to _replace_ the properties meta data.
self
.
_wrapperCheck
(
value
)
if
not
self
.
hasProperty
(
id
):
raise
'Bad Request'
,
'The property %s does not exist.'
%
id
propinfo
=
self
.
propertyInfo
(
id
)
...
...
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