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
499caee1
Commit
499caee1
authored
Aug 02, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged bool property updating fix for PropertySheets from 2.2 branch
parent
6926b56c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
36 deletions
+35
-36
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+12
-15
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+23
-21
No files found.
lib/python/OFS/PropertyManager.py
View file @
499caee1
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property management"""
__version__
=
'$Revision: 1.
29
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
30
$'
[
11
:
-
2
]
import
ExtensionClass
,
Globals
import
ZDOM
...
...
@@ -200,6 +200,13 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
return
0
return
1
def
hasProperty
(
self
,
id
):
"""Return true if object has a property 'id'"""
for
p
in
self
.
_properties
:
if
id
==
p
[
'id'
]:
return
1
return
0
def
getProperty
(
self
,
id
,
d
=
None
):
"""Get the property 'id', returning the optional second
argument or None if no such property is found."""
...
...
@@ -261,13 +268,6 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
value
=
type_converters
[
proptype
](
value
)
self
.
_setPropValue
(
id
,
value
)
def
hasProperty
(
self
,
id
):
"""Return true if object has a property 'id'"""
for
p
in
self
.
_properties
:
if
id
==
p
[
'id'
]:
return
1
return
0
def
_delProperty
(
self
,
id
):
if
not
self
.
hasProperty
(
id
):
raise
ValueError
,
'The property %s does not exist'
%
id
...
...
@@ -321,11 +321,11 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
get turned off will be ignored. Use manage_changeProperties()
instead for most situations.
"""
for
prop
in
self
.
_properties
:
for
prop
in
self
.
propertyMap
()
:
name
=
prop
[
'id'
]
if
'w'
in
prop
.
get
(
'mode'
,
'wd'
):
value
=
REQUEST
.
get
(
name
,
''
)
self
.
_
setPropValue
(
name
,
value
)
self
.
_
updateProperty
(
name
,
value
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
@@ -339,19 +339,16 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
"""
if
REQUEST
is
None
:
props
=
{}
else
:
props
=
REQUEST
else
:
props
=
REQUEST
if
kw
:
for
name
,
value
in
kw
.
items
():
props
[
name
]
=
value
propdict
=
self
.
propdict
()
for
name
,
value
in
props
.
items
():
if
self
.
hasProperty
(
name
):
if
not
'w'
in
propdict
[
name
].
get
(
'mode'
,
'wd'
):
raise
'BadRequest'
,
'%s cannot be changed'
%
name
self
.
_
setPropValue
(
name
,
value
)
self
.
_
updateProperty
(
name
,
value
)
if
REQUEST
is
not
None
:
return
MessageDialog
(
title
=
'Success!'
,
...
...
lib/python/OFS/PropertySheets.py
View file @
499caee1
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.5
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
4
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
,
Globals
from
ZPublisher.Converters
import
type_converters
...
...
@@ -217,12 +217,6 @@ class PropertySheet(Traversable, 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
getPropertyType
(
self
,
id
):
"""Get the type of property 'id', returning None if no
such property exists"""
...
...
@@ -233,6 +227,12 @@ class PropertySheet(Traversable, Persistent, Implicit):
return
md
.
get
(
'type'
,
'string'
)
return
None
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
...
...
@@ -443,11 +443,24 @@ class PropertySheet(Traversable, Persistent, Implicit):
if
REQUEST
is
not
None
:
return
self
.
manage
(
self
,
REQUEST
)
def
manage_editProperties
(
self
,
REQUEST
):
"""Edit object properties via the web."""
for
prop
in
self
.
propertyMap
():
name
=
prop
[
'id'
]
if
'w'
in
prop
.
get
(
'mode'
,
'wd'
):
value
=
REQUEST
.
get
(
name
,
''
)
self
.
_updateProperty
(
name
,
value
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
action
=
'manage'
)
def
manage_changeProperties
(
self
,
REQUEST
=
None
,
**
kw
):
"""Change existing object properties by passing either a mapping
object of name:value pairs {'foo':6} or passing name=value
parameters."""
if
REQUEST
is
None
:
props
=
{}
if
REQUEST
is
None
:
props
=
{}
else
:
props
=
REQUEST
if
kw
:
for
name
,
value
in
kw
.
items
():
...
...
@@ -455,6 +468,8 @@ class PropertySheet(Traversable, Persistent, Implicit):
propdict
=
self
.
_propdict
()
for
name
,
value
in
props
.
items
():
if
self
.
hasProperty
(
name
):
if
not
'w'
in
propdict
[
name
].
get
(
'mode'
,
'wd'
):
raise
'BadRequest'
,
'%s cannot be changed'
%
name
self
.
_updateProperty
(
name
,
value
)
if
REQUEST
is
not
None
:
return
MessageDialog
(
...
...
@@ -462,18 +477,6 @@ class PropertySheet(Traversable, Persistent, Implicit):
message
=
'Your changes have been saved.'
,
action
=
'manage'
)
def
manage_editProperties
(
self
,
REQUEST
):
"""Edit object properties via the web."""
for
prop
in
self
.
propertyMap
():
name
=
prop
[
'id'
]
if
REQUEST
.
has_key
(
name
):
value
=
REQUEST
.
get
(
name
)
self
.
_updateProperty
(
name
,
value
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
action
=
'manage'
)
def
manage_delProperties
(
self
,
ids
=
None
,
REQUEST
=
None
):
"""Delete one or more properties specified by 'ids'."""
if
ids
is
None
:
...
...
@@ -644,7 +647,6 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
return
r
def
get
(
self
,
name
,
default
=
None
):
# pdb.set_trace()
for
propset
in
self
.
__propsets__
():
if
propset
.
id
==
name
or
propset
.
xml_namespace
()
==
name
:
return
propset
.
__of__
(
self
)
...
...
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