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
07c90fa5
Commit
07c90fa5
authored
Feb 10, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added _updateProperty and getPropertyType
parent
1eceda70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+22
-2
No files found.
lib/python/OFS/PropertyManager.py
View file @
07c90fa5
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property management"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
from
ZPublisher.Converters
import
type_converters
...
...
@@ -171,13 +171,33 @@ class PropertyManager:
if
self
.
hasProperty
(
id
):
return
getattr
(
self
,
id
)
return
d
def
getPropertyType
(
self
,
id
):
"""Get the type of property 'id', returning None if no
such property exists"""
for
md
in
self
.
_properties
:
if
md
[
'id'
]
==
id
:
return
md
.
get
(
'type'
,
'string'
)
return
None
def
_setProperty
(
self
,
id
,
value
,
type
=
'string'
):
if
not
self
.
valid_property_id
(
id
):
raise
'Bad Request'
,
'Invalid or duplicate property id'
self
.
_properties
=
self
.
_properties
+
({
'id'
:
id
,
'type'
:
type
},)
setattr
(
self
,
id
,
value
)
def
_updateProperty
(
self
,
id
,
value
):
# 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.
if
not
self
.
hasProperty
(
id
):
raise
'Bad Request'
,
'The property %s does not exist'
%
id
if
type
(
value
)
==
type
(
''
):
proptype
=
self
.
getPropertyType
(
id
)
or
'string'
if
type_converters
.
has_key
(
proptype
):
value
=
type_converters
[
proptype
](
value
)
setattr
(
self
,
id
,
value
)
def
hasProperty
(
self
,
id
):
"""Return true if object has a property 'id'"""
for
p
in
self
.
_properties
:
...
...
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