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
78649564
Commit
78649564
authored
Mar 22, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major rework of Zope Classes to use property sheets
parent
f1429214
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1188 additions
and
326 deletions
+1188
-326
lib/python/ZClasses/Ac_Permissions.py
lib/python/ZClasses/Ac_Permissions.py
+0
-33
lib/python/ZClasses/Basic.py
lib/python/ZClasses/Basic.py
+203
-0
lib/python/ZClasses/Class.py
lib/python/ZClasses/Class.py
+0
-229
lib/python/ZClasses/Manage_Options.py
lib/python/ZClasses/Manage_Options.py
+0
-40
lib/python/ZClasses/Method.py
lib/python/ZClasses/Method.py
+287
-0
lib/python/ZClasses/Property.py
lib/python/ZClasses/Property.py
+190
-0
lib/python/ZClasses/ZClass.py
lib/python/ZClasses/ZClass.py
+329
-0
lib/python/ZClasses/__init__.py
lib/python/ZClasses/__init__.py
+7
-7
lib/python/ZClasses/addCommonSheet.dtml
lib/python/ZClasses/addCommonSheet.dtml
+38
-0
lib/python/ZClasses/addZClass.dtml
lib/python/ZClasses/addZClass.dtml
+61
-15
lib/python/ZClasses/classPermissions.dtml
lib/python/ZClasses/classPermissions.dtml
+30
-0
lib/python/ZClasses/itemProp.dtml
lib/python/ZClasses/itemProp.dtml
+41
-0
lib/python/ZClasses/method_select.dtml
lib/python/ZClasses/method_select.dtml
+2
-2
No files found.
lib/python/ZClasses/Ac_Permissions.py
deleted
100755 → 0
View file @
f1429214
from
OFS.SimpleItem
import
Item
import
Globals
,
Acquisition
class
Ac_Permissions
(
Globals
.
Persistent
,
Item
,
Acquisition
.
Implicit
):
"""Provide very simple tabular editing
"""
id
=
'instance____ac_permissions__'
title
=
'Instance Permissions'
meta_type
=
title
names
=
'Permission name'
,
'Permission methods'
data
=
()
manage_options
=
(
{
'label'
:
'Permissions'
,
'action'
:
'manage_main'
},
)
icon
=
''
def
__getitem__
(
self
,
i
):
return
self
.
data
[
i
]
def
__len__
(
self
):
return
length
(
self
.
data
)
manage_main
=
Globals
.
HTMLFile
(
'method_select'
,
globals
(),
selectops
=
'multiple size=5'
)
def
manage_edit
(
self
,
REQUEST
,
names
=
[],
newname
=
''
,
newmethods
=
[]):
" "
data
=
[]
for
i
in
range
(
len
(
names
)):
name
=
names
[
i
]
methods
=
REQUEST
.
get
(
'methods%s'
%
i
,
None
)
if
methods
:
data
.
append
((
name
,
tuple
(
methods
)))
if
newname
and
newmethods
:
data
.
append
(
newname
,
tuple
(
newmethods
))
self
.
data
=
data
return
self
.
manage_main
(
self
,
REQUEST
)
lib/python/ZClasses/Basic.py
0 → 100644
View file @
78649564
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Basic Item class and class manager
"""
import
Globals
,
OFS
.
PropertySheets
,
OFS
.
Image
,
ExtensionClass
from
string
import
split
,
join
,
strip
class
ZClassBasicSheet
(
OFS
.
PropertySheets
.
PropertySheet
,
OFS
.
PropertySheets
.
View
):
"""Provide management view for item classes
"""
index_html
=
Globals
.
HTMLFile
(
'itemProp'
,
globals
())
def
manage_edit
(
self
,
meta_type
=
''
,
icon
=
''
,
file
=
''
,
REQUEST
=
None
):
"""Set basic item properties.
"""
klass
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_
if
meta_type
:
self
.
setClassAttr
(
'meta_type'
,
meta_type
)
if
file
:
# and hasattr(file, 'content_type'):
if
hasattr
(
klass
,
'ziconImage'
):
klass
.
ziconImage
.
manage_upload
(
file
)
else
:
self
.
setClassAttr
(
'ziconImage'
,
OFS
.
Image
.
Image
(
'ziconImage'
,
''
,
file
))
if
not
icon
:
self
.
setClassAttr
(
'icon'
,
REQUEST
[
'URL1'
]
+
'/ziconImage'
)
if
icon
:
self
.
setClassAttr
(
'icon'
,
icon
)
if
REQUEST
is
not
None
:
return
self
.
index_html
(
self
,
REQUEST
,
manage_tabs_message
=
'Basic properties changed'
)
class
ziconImage
(
ExtensionClass
.
Base
):
"Computed icon attribute"
def
__of__
(
self
,
parent
):
return
_ziconImage
()
ziconImage
=
ziconImage
()
def
icon_
(
self
):
icon
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_
.
icon
class
_ziconImage
(
ExtensionClass
.
Base
):
"The real Computed icon attribute"
def
__of__
(
self
,
ps
):
klass
=
ps
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_
return
klass
.
ziconImage
class
ZClassViewsSheet
(
OFS
.
PropertySheets
.
PropertySheet
,
OFS
.
PropertySheets
.
View
):
"""Provide an options management view
"""
def
data
(
self
):
klass
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_
return
map
(
lambda
d
:
(
d
[
'label'
],
(
d
[
'action'
],)),
klass
.
manage_options
)
index_html
=
Globals
.
HTMLFile
(
'method_select'
,
globals
(),
selectops
=
''
)
def
manage_edit
(
self
,
REQUEST
,
names
=
[],
newname
=
''
,
newmethods
=
[]):
" "
data
=
[]
for
i
in
range
(
len
(
names
)):
name
=
names
[
i
]
methods
=
REQUEST
.
get
(
'methods%s'
%
i
,
None
)
if
methods
:
data
.
append
((
name
,
tuple
(
methods
)))
if
newname
and
newmethods
:
data
.
append
((
newname
,
tuple
(
newmethods
)))
__traceback_info__
=
data
ddata
=
map
(
lambda
i
:
{
'label'
:
i
[
0
],
'action'
:
i
[
1
][
0
]},
data
)
self
.
setClassAttr
(
'manage_options'
,
ddata
)
return
self
.
index_html
(
self
,
REQUEST
)
class
ZClassPermissionsSheet
(
OFS
.
PropertySheets
.
PropertySheet
,
OFS
.
PropertySheets
.
View
):
"Manage class permissions"
index_html
=
Globals
.
HTMLFile
(
'classPermissions'
,
globals
())
def
manage_edit
(
self
,
REQUEST
,
selected
=
[],
newPermission
=
''
):
"Remove some permissions"
perms
=
self
.
classDefinedPermissions
()
changed
=
0
message
=
[]
for
s
in
selected
:
if
s
in
perms
:
perms
.
remove
(
s
)
changed
=
1
else
:
message
.
append
(
'Invalid permission: %s'
%
s
)
newPermission
=
strip
(
newPermission
)
if
newPermission
:
if
newPermission
in
perms
:
message
.
append
(
'The new permission, %s, is already in use'
%
s
)
else
:
perms
.
append
(
newPermission
)
changed
=
1
if
changed
:
self
.
setClassAttr
(
'__ac_permissions__'
,
tuple
(
map
(
lambda
p
:
(
p
,()),
perms
))
)
else
:
message
.
append
(
'Permissions are unchanged.'
)
if
message
:
message
=
join
(
message
,
'<br>
\
n
'
)
return
self
.
index_html
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
lib/python/ZClasses/Class.py
deleted
100755 → 0
View file @
f1429214
from
OFS
import
Folder
import
Globals
,
string
,
OFS
.
SimpleItem
,
Acquisition
,
AccessControl
.
Role
from
ZPublisher.mapply
import
mapply
from
Manage_Options
import
Manage_Options
from
Ac_Permissions
import
Ac_Permissions
from
ExtensionClass
import
Base
from
App.FactoryDispatcher
import
FactoryDispatcher
class
Item
(
OFS
.
SimpleItem
.
Item
,
Globals
.
Persistent
,
Acquisition
.
Implicit
,
AccessControl
.
Role
.
RoleManager
,
):
"""Basic instances
"""
manage_options
=
(
{
'label'
:
'Security'
,
'action'
:
'manage_access'
},
)
__ac_permissions__
=
(
(
'View management screens'
,
(
'manage_tabs'
,)),
(
'Change permissions'
,
(
'manage_access'
,)
),
)
builtins
=
(
(
'OFS.Folder Folder'
,
'Zope Folder'
,
Folder
.
Folder
),
(
'OFS.SimpleItem Item'
,
'Minimal Item'
,
Item
),
)
builtin_classes
=
{}
builtin_names
=
{}
for
id
,
name
,
c
in
builtins
:
builtin_classes
[
id
]
=
c
builtin_names
[
id
]
=
name
class
PersistentClass
(
Base
):
def
__class_init__
(
self
):
pass
manage_addZClassForm
=
Globals
.
HTMLFile
(
'addZClass'
,
globals
(),
default_class_
=
'OFS.SimpleItem Item'
)
def
manage_addZClass
(
self
,
id
,
title
=
''
,
base
=
[],
REQUEST
=
None
):
"""Add a Z Class
"""
if
not
base
:
base
=
(
'OFS.SimpleItem Item'
,)
bases
=
[
PersistentClass
]
for
b
in
base
:
if
builtin_classes
.
has_key
(
b
):
bases
.
append
(
builtin_classes
[
b
])
else
:
bases
.
append
(
getattr
(
self
,
b
).
_zclass_
)
bases
=
tuple
(
bases
)
self
.
_setObject
(
id
,
ZClass
(
id
,
title
,
bases
))
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
def
manage_subclassableClassNames
(
self
):
r
=
{}
r
.
update
(
builtin_names
)
while
1
:
if
not
hasattr
(
self
,
'objectItems'
):
break
for
k
,
v
in
self
.
objectItems
():
if
hasattr
(
v
,
'_zclass_'
)
and
not
r
.
has_key
(
k
):
r
[
k
]
=
v
.
title_and_id
()
if
not
hasattr
(
self
,
'aq_parent'
):
break
self
=
self
.
aq_parent
r
=
r
.
items
()
r
.
sort
()
return
r
class
Template
:
_p_oid
=
_p_jar
=
__module__
=
None
_p_changed
=
0
icon
=
''
class
ZClass
(
Folder
.
Folder
):
"""Zope Class
"""
meta_type
=
"Z Class"
icon
=
""
instance__meta_type
=
'instance'
instance__icon
=
''
_properties
=
({
'id'
:
'title'
,
'type'
:
'string'
},
{
'id'
:
'instance__meta_type'
,
'type'
:
'string'
},
{
'id'
:
'instance__icon'
,
'type'
:
'string'
},
)
_objects
=
(
{
'id'
:
'instance__manage_options'
,
'meta_type'
:
Manage_Options
.
meta_type
},
{
'id'
:
'instance____ac_permissions__'
,
'meta_type'
:
Ac_Permissions
.
meta_type
},
)
manage_main
=
Globals
.
HTMLFile
(
'contents'
,
globals
())
def
all_meta_types
(
self
):
return
ZClass
.
inheritedAttribute
(
'all_meta_types'
)(
self
)
+
(
{
'name'
:
'Instance icon'
,
'action'
:
'manage_addInstanceIconForm'
},
)
def
__init__
(
self
,
id
,
title
,
bases
):
self
.
id
=
id
self
.
title
=
title
dict
=
{}
dict
.
update
(
Template
.
__dict__
)
dict
[
'__doc__'
]
=
dict
[
'meta_type'
]
=
self
.
instance__meta_type
=
title
or
id
self
.
_zclass_
=
c
=
type
(
bases
[
0
])(
id
,
bases
,
dict
)
self
.
instance__manage_options
=
c
.
manage_options
=
Manage_Options
()
self
.
instance____ac_permissions__
=
c
.
__ac_permissions__
=
Ac_Permissions
()
def
index_html
(
self
,
id
,
REQUEST
):
"""Create Z instance
"""
i
=
mapply
(
self
.
_zclass_
,
(),
REQUEST
)
if
not
hasattr
(
i
,
'id'
):
i
.
id
=
id
folder
=
durl
=
None
if
hasattr
(
self
,
'Destination'
):
try
:
d
=
self
.
Destination
if
d
.
im_self
.
__class__
is
FactoryDispatcher
:
folder
=
d
()
durl
=
self
.
DestinationURL
()
except
:
pass
if
folder
is
None
:
folder
=
self
.
aq_parent
folder
.
_setObject
(
id
,
i
)
if
REQUEST
.
has_key
(
'RESPONSE'
):
if
durl
is
None
:
durl
=
REQUEST
[
'URL2'
]
REQUEST
[
'RESPONSE'
].
redirect
(
durl
+
'/manage_workspace'
)
def
propertyLabel
(
self
,
id
):
"""Return a label for the given property id
"""
if
id
[:
10
]
==
'instance__'
:
return
id
[
10
:]
return
id
def
_setProperty
(
self
,
id
,
value
,
type
=
'string'
):
return
ZClass
.
inheritedAttribute
(
'_setProperty'
)(
self
,
'instance__'
+
id
,
value
,
type
)
def
_setPropValue
(
self
,
id
,
value
):
setattr
(
self
,
id
,
value
)
z
=
self
.
_zclass_
setattr
(
z
,
id
[
10
:],
value
)
z
.
_p_changed
=
1
get_transaction
().
register
(
z
)
def
_delPropValue
(
self
,
id
):
delattr
(
self
,
id
)
z
=
self
.
_zclass_
delattr
(
z
,
id
[
10
:])
z
.
_p_changed
=
1
get_transaction
().
register
(
z
)
def
_setObject
(
self
,
id
,
object
,
*
whatever
):
ZClass
.
inheritedAttribute
(
'_setObject'
)(
self
,
'instance__'
+
id
,
object
)
_reserved
=
()
def
_setOb
(
self
,
id
,
object
):
if
id
in
self
.
_reserved
:
raise
'Input Error'
,
'The id %s is reserved'
%
id
setattr
(
self
,
id
,
object
)
z
=
self
.
_zclass_
setattr
(
z
,
id
[
10
:],
object
)
z
.
_p_changed
=
1
get_transaction
().
register
(
z
)
def
_delOb
(
self
,
id
):
delattr
(
self
,
id
)
z
=
self
.
_zclass_
delattr
(
z
,
id
[
10
:])
z
.
_p_changed
=
1
get_transaction
().
register
(
z
)
def
all_methods
(
self
):
r
=
{}
for
id
in
self
.
objectIds
():
id
=
id
[
10
:]
if
id
in
(
'manage_options'
,
'__ac_permissions__'
):
continue
r
[
id
]
=
1
perms
=
self
.
_zclass_
.
inheritedAttribute
(
'__ac_permissions__'
)
if
hasattr
(
perms
,
'im_func'
):
perms
=
perms
.
im_func
# Waaa
for
pname
,
methods
in
perms
:
for
id
in
methods
:
if
id
:
r
[
id
]
=
1
r
=
r
.
keys
()
r
.
sort
()
return
r
manage_addInstanceIconForm
=
Globals
.
HTMLFile
(
'addIcon'
,
globals
())
def
manage_addInstanceIcon
(
self
,
id
,
title
,
file
,
REQUEST
):
" "
id
=
self
.
manage_addImage
(
id
,
file
,
title
)
s
=
REQUEST
[
'BASE1'
]
self
.
manage_changeProperties
(
instance__icon
=
REQUEST
[
'URL1'
][
len
(
s
)
+
1
:]
+
'/instance__'
+
id
)
return
self
.
manage_main
(
self
,
REQUEST
)
def
manage_addDTMLMethod
(
self
,
id
,
title
=
''
,
file
=
''
,
REQUEST
=
None
,
submit
=
None
):
if
not
file
:
file
=
default_dm_html
return
self
.
inheritedAttribute
(
'manage_addDTMLMethod'
)(
self
,
id
,
title
,
file
,
REQUEST
,
submit
)
default_dm_html
=
"""<html>
<head><title><!--#var document_title--></title></head>
<body bgcolor="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>This is the <!--#var document_id--> Document in
the <!--#var title_and_id--> Folder.</P>
</body></html>
"""
lib/python/ZClasses/Manage_Options.py
deleted
100755 → 0
View file @
f1429214
from
OFS.SimpleItem
import
Item
import
Globals
,
Acquisition
class
Manage_Options
(
Globals
.
Persistent
,
Item
,
Acquisition
.
Implicit
):
"""Provide very simple tabular editing
"""
id
=
'instance__manage_options'
title
=
'Instance view definitions'
meta_type
=
title
names
=
'Permission name'
,
'Permission methods'
data
=
()
ddata
=
()
manage_options
=
(
{
'label'
:
'Options'
,
'action'
:
'manage_main'
},
)
icon
=
''
def
__getitem__
(
self
,
i
):
return
self
.
ddata
[
i
]
def
__len__
(
self
):
return
len
(
self
.
data
)
manage_main
=
Globals
.
HTMLFile
(
'method_select'
,
globals
(),
selectops
=
''
)
def
manage_edit
(
self
,
REQUEST
,
names
=
[],
newname
=
''
,
newmethods
=
[]):
" "
data
=
[]
for
i
in
range
(
len
(
names
)):
name
=
names
[
i
]
methods
=
REQUEST
.
get
(
'methods%s'
%
i
,
None
)
if
methods
:
data
.
append
((
name
,
tuple
(
methods
)))
if
newname
and
newmethods
:
data
.
append
((
newname
,
tuple
(
newmethods
)))
self
.
data
=
data
__traceback_info__
=
data
self
.
ddata
=
map
(
lambda
i
:
{
'label'
:
i
[
0
],
'action'
:
i
[
1
][
0
]},
data
)
return
self
.
manage_main
(
self
,
REQUEST
)
lib/python/ZClasses/Method.py
0 → 100644
View file @
78649564
This diff is collapsed.
Click to expand it.
lib/python/ZClasses/Property.py
0 → 100644
View file @
78649564
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Provide management of common instance property sheets
"""
import
OFS.PropertySheets
,
Globals
,
OFS
.
SimpleItem
,
OFS
.
PropertyManager
import
Acquisition
class
ClassCaretaker
:
def
__init__
(
self
,
klass
):
self
.
__dict__
[
'_k'
]
=
klass
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_k
,
name
)
def
__setattr__
(
self
,
name
,
v
):
klass
=
self
.
_k
setattr
(
klass
,
name
,
v
)
if
not
klass
.
_p_changed
:
get_transaction
().
register
(
klass
)
klass
.
_p_changed
=
1
class
ZCommonSheet
(
OFS
.
PropertySheets
.
PropertySheet
,
OFS
.
SimpleItem
.
Item
):
"Property Sheet that has properties common to all instances"
meta_type
=
"Common Instance Property Sheet"
_properties
=
()
manage_options
=
(
{
'label'
:
'Properties'
,
'action'
:
'manage_propertiesForm'
},
)
def
__init__
(
self
,
id
,
title
):
self
.
id
=
id
self
.
title
=
title
self
.
md
=
{}
def
v_self
(
self
):
klass
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
aq_parent
.
_zclass_
return
ClassCaretaker
(
klass
)
def
p_self
(
self
):
return
self
class
ZInstanceSheet
(
OFS
.
PropertySheets
.
FixedSchema
,
OFS
.
PropertySheets
.
View
,
):
"Waaa this is too hard"
def
v_self
(
self
):
return
self
.
aq_inner
.
aq_parent
.
aq_parent
def
rclass
(
klass
):
if
klass
.
_p_changed
==
0
:
get_transaction
().
register
(
klass
)
klass
.
_p_changed
=
1
class
ZInstanceSheetsSheet
(
OFS
.
PropertySheets
.
View
,
OFS
.
ObjectManager
.
ObjectManager
):
"Manage common property sheets"
# Note that we need to make sure we add and remove
# instance sheets.
def
_setOb
(
self
,
id
,
value
):
setattr
(
self
,
id
,
value
)
pc
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_propertysheets_class
setattr
(
pc
,
id
,
ZInstanceSheet
(
id
,
value
))
pc
.
__propset_attrs__
=
tuple
(
map
(
lambda
o
:
o
[
'id'
],
self
.
_objects
))
rclass
(
pc
)
def
_delOb
(
self
,
id
,
value
):
delattr
(
self
,
id
)
pc
=
self
.
aq_inner
.
aq_parent
.
aq_parent
.
_zclass_propertysheets_class
delattr
(
pc
,
id
)
pc
.
__propset_attrs__
=
tuple
(
map
(
lambda
o
:
o
[
0
],
self
.
_objects
))
rclass
(
pc
)
meta_types
=
(
Globals
.
Dictionary
(
name
=
ZCommonSheet
.
meta_type
,
action
=
'manage_addCommonSheetForm'
),
)
index_html
=
Globals
.
HTMLFile
(
'OFS/main'
)
manage_addCommonSheetForm
=
Globals
.
HTMLFile
(
'addCommonSheet'
,
globals
())
def
manage_addCommonSheet
(
self
,
id
,
title
,
REQUEST
=
None
):
"Add a property sheet"
o
=
ZCommonSheet
(
id
,
title
)
self
.
_setObject
(
id
,
o
)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
def
klass_sequence
(
klass
,
attr
,
result
=
None
):
if
result
is
None
:
result
=
{}
if
hasattr
(
klass
,
attr
):
for
i
in
getattr
(
klass
,
attr
):
result
[
i
]
=
1
for
klass
in
klass
.
__bases__
:
klass_sequence
(
klass
,
attr
,
result
)
return
result
class
ZInstanceSheets
(
OFS
.
PropertySheets
.
PropertySheets
,
Globals
.
Persistent
):
" "
__propset_attrs__
=
()
def
__propsets__
(
self
):
propsets
=
ZInstanceSheets
.
inheritedAttribute
(
'__propsets__'
)(
self
)
r
=
[]
for
id
in
klass_sequence
(
self
.
__class__
,
'__propset_attrs__'
).
keys
():
r
.
append
(
getattr
(
self
,
id
))
return
propsets
+
tuple
(
r
)
lib/python/ZClasses/ZClass.py
0 → 100755
View file @
78649564
This diff is collapsed.
Click to expand it.
lib/python/ZClasses/__init__.py
View file @
78649564
...
@@ -14,24 +14,24 @@ needed by a product and to define product meta data.
...
@@ -14,24 +14,24 @@ needed by a product and to define product meta data.
This sample product publishes a folder-ish and a simple object.
This sample product publishes a folder-ish and a simple object.
$Id: __init__.py,v 1.
2 1999/02/22 20:50:02
jim Exp $'''
$Id: __init__.py,v 1.
3 1999/03/22 17:45:37
jim Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
from
ImageFile
import
ImageFile
from
ImageFile
import
ImageFile
import
Class
import
Z
Class
# Names of objects added by this product:
# Names of objects added by this product:
meta_types
=
(
meta_types
=
(
{
'name'
:
Class
.
ZClass
.
meta_type
,
{
'name'
:
Z
Class
.
ZClass
.
meta_type
,
'action'
:
'manage_addZClassForm'
},
'action'
:
'manage_addZClassForm'
},
)
)
# Attributes (usually "methods") to be added to folders to support
# Attributes (usually "methods") to be added to folders to support
# creating objects:
# creating objects:
methods
=
{
methods
=
{
'manage_addZClassForm'
:
Class
.
manage_addZClassForm
,
'manage_addZClassForm'
:
Z
Class
.
manage_addZClassForm
,
'manage_addZClass'
:
Class
.
manage_addZClass
,
'manage_addZClass'
:
Z
Class
.
manage_addZClass
,
'manage_subclassableClassNames'
:
Class
.
manage_subclassableClassNames
,
'manage_subclassableClassNames'
:
Z
Class
.
manage_subclassableClassNames
,
}
}
...
...
lib/python/ZClasses/addCommonSheet.dtml
0 → 100644
View file @
78649564
<HTML>
<HEAD>
<TITLE>Add Common Instance Property Sheet</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add Common Instance Property Sheet</H2>
<FORM ACTION="manage_addCommonSheet" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR><TD COLSPAN="2"><BR></TD></TR>
<TR>
<TD></TD>
<TD>
<BR><INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
lib/python/ZClasses/addZClass.dtml
View file @
78649564
...
@@ -5,35 +5,81 @@
...
@@ -5,35 +5,81 @@
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add ZClass</H2>
<H2>Add ZClass</H2>
<FORM ACTION="manage_addZClass" METHOD="POST">
<!--#with "_(selected=[], unselected=[], baseclasses=[], id='', title='',
<TABLE CELLSPACING="2">
all=manage_subclassableClassNames(),
)"-->
<!--#with REQUEST-->
<!--#with "_(
selected=_.reorder(
all,
with = baseclasses+
(REQUEST.get('manage_addZClassForm','')==' -> '
and unselected or []),
without= (REQUEST.get('manage_addZClassForm','')==' <- '
and selected or [])
),
)"-->
<!--#with "_(unselected=_.reorder(all, without=selected))"-->
<FORM ACTION="." METHOD="POST"><TABLE CELLSPACING="2">
<TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Id</TH>
<TH ALIGN="LEFT" VALIGN="TOP">Id</TH>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="id" SIZE="40"></TD>
<TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="3">
<INPUT TYPE="TEXT" NAME="id" SIZE="40" VALUE="<!--#var id-->">
</TD>
</TR>
</TR>
<TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>Title</EM></TH>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>Title</EM></TH>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="40"></TD>
<TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="3">
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<!--#var title-->">
</TD>
</TR>
</TR>
<TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>Base Class</EM></TH>
<TH ALIGN="LEFT" VALIGN="TOP"></TH>
<TD ALIGN="LEFT" VALIGN="TOP">
Unselected<BR>classes:<BR>
<SELECT NAME="unselected:list" size=9 multiple>
<!--#in unselected-->
<OPTION VALUE="<!--#var sequence-key-->"
><!--#var sequence-item--></OPTION>
<!--#/in-->
</SELECT>
</TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE">
<!--#in selected-->
<input type=hidden name="baseclasses:list"
value="<!--#var sequence-key-->">
<!--#/in-->
<INPUT TYPE="SUBMIT" NAME="manage_addZClassForm:method"
VALUE=" -> ">
<BR>
<INPUT TYPE="SUBMIT" NAME="manage_addZClassForm:method"
VALUE=" <- ">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME="base:list">
<STRONG><EM>Selected<br>base classes:</EM></STRONG><BR>
<!--#in manage_subclassableClassNames-->
<SELECT NAME="selected:list" size=9 multiple>
<!--#in selected-->
<OPTION VALUE="<!--#var sequence-key-->"
<OPTION VALUE="<!--#var sequence-key-->"
<!--#if "_['sequence-key'] == default_class_"-->SELECTED
><!--#var sequence-item--></OPTION>
<!--#/if-->
><!--#var sequence-item--></OPTION>
<!--#/in-->
<!--#/in-->
</SELECT>
</SELECT>
</TD>
</TD>
</TR>
</TR>
<TR><TD></TD>
<TR><TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE=" Add "></TD>
<TD><BR><INPUT TYPE="SUBMIT" NAME="manage_addZClass:method"
VALUE=" Add "></TD>
</TR>
</TR>
</TABLE>
</TABLE></FORM>
</FORM>
</BODY>
<!--#/with-->
</HTML>
<!--#/with-->
<!--#/with-->
<!--#/with-->
</BODY></HTML>
lib/python/ZClasses/classPermissions.dtml
0 → 100644
View file @
78649564
<html><head><title>
Security
</title></head>
<body
bgcolor=
"#ffffff"
link=
"#000099"
vlink=
"#555555"
alink=
"#77003b"
>
<!--#if manage_tabs-->
<!--#var manage_tabs-->
<!--#/if manage_tabs-->
<form
action=
manage_edit
>
<table>
<tr><td></td><th>
Permission
</th></tr>
<!--#in classDefinedPermissions-->
<tr>
<td><input
type=
checkbox
name=
selected:list
value=
"<!--#var sequence-item-->"
></td>
<td>
<!--#var sequence-item-->
</td>
</tr>
<!--#/in-->
<tr>
<td></td>
<td>
New permission:
<input
name=
newPermission
></td>
</tr>
<tr>
<td></td>
<td>
<input
type=
submit
value=
" Change "
>
</td>
</tr>
</table>
</form>
</body></html>
lib/python/ZClasses/itemProp.dtml
0 → 100644
View file @
78649564
<HTML><HEAD><TITLE>Basic Instance Properties</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<p>Instance Icons are displayed with images in management interfaces.
Select an image file from your local computer by clicking the
<em>Browse</em> button. The image you select will be uploaded
to the class for use by instances.</p>
<p>The instance icon property will be set to give a path to the image.
The path will be based on the current location of this class and
will need to be adjusted if the class is moved.</p>
<FORM ACTION="manage_edit" METHOD="POST"
ENCTYPE="multipart/form-data">
<TABLE CELLSPACING="2">
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">meta type</TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="meta_type" SIZE="40"
value="<!--#var meta_type-->">
</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>icon</EM></TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="icon" SIZE="40"
value="<!--#var icon-->">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Icon image</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="file" NAME="file" SIZE="25" VALUE="">
</TD>
</TR>
<TR>
<TD></TD><TD><BR><INPUT TYPE="SUBMIT" VALUE=" Change "></TD>
</TR>
</TABLE></FORM></BODY></HTML>
lib/python/ZClasses/method_select.dtml
View file @
78649564
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<!--#with "_.namespace(methods=_['sequence-item'])"-->
<!--#with "_.namespace(methods=_['sequence-item'])"-->
<select
name=
"<!--#var "
'
methods
%
s:list
'
%
_
['
sequence-index
']"
--
>
"
<select
name=
"<!--#var "
'
methods
%
s:list
'
%
_
['
sequence-index
']"
--
>
"
<!--#var selectops-->
>
<!--#var selectops-->
>
<!--#in
all_method
s-->
<!--#in
zclass_candidate_view_action
s-->
<option
<option
<!
--#if
"
_
['
sequence-item
']
in
methods
"
--
>
SELECTED
<!
--#if
"
_
['
sequence-item
']
in
methods
"
--
>
SELECTED
<!--#/if-->
>
<!--#var sequence-item-->
</option>
<!--#/if-->
>
<!--#var sequence-item-->
</option>
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<th
align=
left
valign=
top
>
New:
<input
type=
text
name=
"newname"
size=
20
></th>
<th
align=
left
valign=
top
>
New:
<input
type=
text
name=
"newname"
size=
20
></th>
<td
align=
left
valign=
top
>
<td
align=
left
valign=
top
>
<select
name=
newmethods:list
<!
--#var
selectops--
>
>
<select
name=
newmethods:list
<!
--#var
selectops--
>
>
<!--#in
all_method
s-->
<!--#in
zclass_candidate_view_action
s-->
<option>
<!--#var sequence-item-->
</option>
<option>
<!--#var sequence-item-->
</option>
<!--#/in-->
<!--#/in-->
</select></td>
</select></td>
...
...
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