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
dc241f2a
Commit
dc241f2a
authored
Jun 24, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed to use new object management hooks.
parent
152645d3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
124 additions
and
141 deletions
+124
-141
lib/python/AccessControl/User.py
lib/python/AccessControl/User.py
+9
-11
lib/python/App/Factory.py
lib/python/App/Factory.py
+22
-11
lib/python/App/Product.py
lib/python/App/Product.py
+7
-34
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+17
-16
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+27
-23
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+5
-9
lib/python/Products/OFSP/Draft.py
lib/python/Products/OFSP/Draft.py
+12
-19
lib/python/Products/OFSP/Version.py
lib/python/Products/OFSP/Version.py
+20
-14
lib/python/ZClasses/Property.py
lib/python/ZClasses/Property.py
+5
-4
No files found.
lib/python/AccessControl/User.py
View file @
dc241f2a
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Access control package"""
__version__
=
'$Revision: 1.
79
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
80
$'
[
11
:
-
2
]
import
Globals
,
App
.
Undo
,
socket
,
regex
from
Globals
import
HTMLFile
,
MessageDialog
,
Persistent
,
PersistentMapping
...
...
@@ -596,17 +596,15 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
def
user_names
(
self
):
return
self
.
getUserNames
()
# Copy/Paste support
def
manage_beforeDelete
(
self
,
item
,
container
):
if
item
is
self
:
try
:
del
container
.
__allow_groups__
except
:
pass
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
if
hasattr
(
container
,
'aq_base'
):
container
=
container
.
aq_base
if
hasattr
(
container
,
'acl_users'
):
raise
TypeError
,
(
'Target already contains a UserFolder.'
)
def
_postCopy
(
self
,
container
,
op
=
0
):
container
.
__allow_groups__
=
container
.
acl_users
def
manage_afterAdd
(
self
,
item
,
container
):
if
item
is
self
:
if
hasattr
(
self
,
'aq_base'
):
self
=
self
.
aq_base
container
.
__allow_groups__
=
self
def
_setId
(
self
,
id
):
if
id
!=
self
.
id
:
...
...
lib/python/App/Factory.py
View file @
dc241f2a
...
...
@@ -84,10 +84,11 @@
##############################################################################
__doc__
=
'''Principia Factories
$Id: Factory.py,v 1.1
0 1999/06/16 14:15:27 brian
Exp $'''
__version__
=
'$Revision: 1.1
0
$'
[
11
:
-
2
]
$Id: Factory.py,v 1.1
1 1999/06/24 19:24:55 jim
Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
import
OFS.SimpleItem
,
Acquisition
,
Globals
import
Product
class
Factory
(
Globals
.
Persistent
,
Acquisition
.
Implicit
,
OFS
.
SimpleItem
.
Item
):
"Model factory meta-data"
...
...
@@ -101,12 +102,13 @@ class Factory(Globals.Persistent, Acquisition.Implicit, OFS.SimpleItem.Item):
{
'label'
:
'Security'
,
'action'
:
'manage_access'
},
)
def
__init__
(
self
,
id
,
title
,
object_type
,
initial
,
product
):
def
__init__
(
self
,
id
,
title
,
object_type
,
initial
,
product
=
None
):
self
.
id
=
id
self
.
title
=
title
self
.
object_type
=
object_type
self
.
initial
=
initial
self
.
__of__
(
product
).
_register
()
if
product
is
not
None
:
self
.
__of__
(
product
).
_register
()
def
manage_edit
(
self
,
title
,
object_type
,
initial
,
REQUEST
=
None
):
"Modify factory properties."
...
...
@@ -117,13 +119,23 @@ class Factory(Globals.Persistent, Acquisition.Implicit, OFS.SimpleItem.Item):
self
.
_register
()
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
if
container
.
__class__
is
not
Product
:
raise
TypeError
,
(
'Factories can only be copied to <b>products</b>.'
)
def
manage_afterAdd
(
self
,
item
,
container
):
if
hasattr
(
self
,
'aq_parent'
):
container
=
self
.
aq_parent
elif
item
is
not
self
:
container
=
None
def
_postCopy
(
self
,
container
,
op
=
0
):
self
.
_register
()
if
getattr
(
container
,
'__class__'
,
None
)
is
Product
.
Product
:
self
.
_register
()
def
manage_beforeDelete
(
self
,
item
,
container
):
if
hasattr
(
self
,
'aq_parent'
):
container
=
self
.
aq_parent
elif
item
is
not
self
:
container
=
None
if
getattr
(
container
,
'__class__'
,
None
)
is
Product
.
Product
:
self
.
_unregister
()
def
_register
(
self
):
# Register with the product folder
...
...
@@ -137,7 +149,6 @@ class Factory(Globals.Persistent, Acquisition.Implicit, OFS.SimpleItem.Item):
product
.
aq_acquire
(
'_manage_remove_product_meta_type'
)(
product
,
self
.
id
,
self
.
object_type
)
manage_main
=
Globals
.
HTMLFile
(
'editFactory'
,
globals
())
def
index_html
(
self
,
REQUEST
):
...
...
lib/python/App/Product.py
View file @
dc241f2a
...
...
@@ -111,7 +111,7 @@ from OFS.Folder import Folder
import
regex
,
zlib
,
Globals
,
cPickle
,
marshal
,
rotor
from
string
import
rfind
,
atoi
,
find
,
strip
,
join
from
Factory
import
Factory
import
ZClasses
import
ZClasses
,
ZClasses
.
ZClass
class
ProductFolder
(
Folder
):
"Manage a collection of Products"
...
...
@@ -142,13 +142,6 @@ class ProductFolder(Folder):
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
def
_delObject
(
self
,
id
):
try
:
for
factory
in
getattr
(
self
,
id
).
_factories
():
factory
.
_unregister
()
except
:
pass
ProductFolder
.
inheritedAttribute
(
'_delObject'
)(
self
,
id
)
def
_canCopy
(
self
,
op
=
0
):
return
0
...
...
@@ -206,39 +199,15 @@ class Product(Folder):
def
manage_addPrincipiaFactory
(
self
,
id
,
title
,
object_type
,
initial
,
REQUEST
=
None
):
' '
i
=
Factory
(
id
,
title
,
object_type
,
initial
,
self
)
i
=
Factory
(
id
,
title
,
object_type
,
initial
)
self
.
_setObject
(
id
,
i
)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
def
_delObject
(
self
,
id
,
dp
=
1
):
o
=
getattr
(
self
,
id
)
if
o
.
meta_type
==
Factory
.
meta_type
:
o
.
_unregister
()
Product
.
inheritedAttribute
(
'_delObject'
)(
self
,
id
,
dp
=
1
)
def
__init__
(
self
,
id
,
title
):
self
.
id
=
id
self
.
title
=
title
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
if
container
.
__class__
is
not
ProductFolder
:
raise
TypeError
,
(
'Products can only be copied to <b>product folders</b>.'
)
def
_postCopy
(
self
,
container
,
op
=
0
):
for
factory
in
self
.
_factories
():
factory
.
_register
()
def
_factories
(
self
):
r
=
[]
append
=
r
.
append
for
o
in
self
.
__dict__
.
values
():
if
hasattr
(
o
,
'meta_type'
)
and
o
.
meta_type
==
Factory
.
meta_type
:
append
(
o
.
__of__
(
self
))
return
r
def
Destination
(
self
):
"Return the destination for factory output"
return
self
...
...
@@ -440,8 +409,12 @@ def initializeProduct(productp, name, home, app):
if
old
is
not
None
:
app
.
_manage_remove_product_meta_type
(
product
)
products
.
_delObject
(
name
)
for
id
,
v
in
old
.
objectValues
():
try
:
product
.
_setObject
(
id
,
v
)
except
:
pass
products
.
_setObject
(
name
,
product
)
product
.
__of__
(
products
).
_postCopy
(
products
)
#
product.__of__(products)._postCopy(products)
product
.
manage_options
=
Folder
.
manage_options
product
.
icon
=
'p_/InstalledProduct_icon'
product
.
version
=
fver
...
...
lib/python/OFS/CopySupport.py
View file @
dc241f2a
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.3
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
from
marshal
import
loads
,
dumps
...
...
@@ -183,24 +183,25 @@ class CopyContainer(ExtensionClass.Base):
try
:
ob
=
m
.
bind
()
except
:
raise
CopyError
,
eNotFound
self
.
_verifyObjectPaste
(
ob
,
REQUEST
)
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
op
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'Copy Error'
,
message
=
sys
.
exc_value
,
action
=
'manage_main'
)
#
try: ob._notifyOfCopyTo(self, op=op)
#
except: raise CopyError, MessageDialog(
#
title='Copy Error',
#
message=sys.exc_value,
#
action ='manage_main')
oblist
.
append
(
ob
)
if
op
==
0
:
# Copy operation
for
ob
in
oblist
:
if
not
ob
.
cb_isCopyable
():
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
ob
=
ob
.
_getCopy
(
self
)
ob
.
manage_afterClone
(
ob
)
id
=
_get_id
(
self
,
absattr
(
ob
.
id
))
ob
.
_setId
(
id
)
self
.
_setObject
(
id
,
ob
)
ob
=
ob
.
__of__
(
self
)
ob
.
_postCopy
(
self
,
op
=
0
)
#
ob=ob.__of__(self)
#
ob._postCopy(self, op=0)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
,
...
...
@@ -218,8 +219,8 @@ class CopyContainer(ExtensionClass.Base):
id
=
_get_id
(
self
,
id
)
ob
.
_setId
(
id
)
self
.
_setObject
(
id
,
ob
)
ob
=
ob
.
__of__
(
self
)
ob
.
_postCopy
(
self
,
op
=
1
)
#
ob=ob.__of__(self)
#
ob._postCopy(self, op=1)
if
REQUEST
is
not
None
:
REQUEST
[
'RESPONSE'
].
setCookie
(
'cp_'
,
'deleted'
,
...
...
@@ -251,10 +252,10 @@ class CopyContainer(ExtensionClass.Base):
self
.
_delObject
(
id
,
dp
=
0
)
if
hasattr
(
ob
,
'aq_base'
):
ob
=
ob
.
aq_base
self
.
_setObject
(
new_id
,
ob
)
ob
=
ob
.
__of__
(
self
)
ob
.
_setId
(
new_id
)
ob
.
_postCopy
(
self
,
op
=
1
)
self
.
_setObject
(
new_id
,
ob
)
#ob=ob.__of__(self)
#ob._postCopy(self, op=1)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
return
None
...
...
@@ -282,8 +283,8 @@ class CopyContainer(ExtensionClass.Base):
ob
=
ob
.
_getCopy
(
self
)
ob
.
_setId
(
id
)
self
.
_setObject
(
id
,
ob
)
ob
=
ob
.
__of__
(
self
)
ob
.
_postCopy
(
self
,
op
=
0
)
#
ob=ob.__of__(self)
#
ob._postCopy(self, op=0)
return
ob
def
cb_dataValid
(
self
):
...
...
lib/python/OFS/ObjectManager.py
View file @
dc241f2a
...
...
@@ -84,9 +84,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.7
3 1999/06/18 00:32:39 amos
Exp $"""
$Id: ObjectManager.py,v 1.7
4 1999/06/24 19:27:16 jim
Exp $"""
__version__
=
'$Revision: 1.7
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.7
4
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
App
.
Undo
,
Globals
,
CopySupport
import
os
,
App
.
FactoryDispatcher
,
ts_regex
,
Products
...
...
@@ -205,6 +205,8 @@ class ObjectManager(
except
:
t
=
None
self
.
_objects
=
self
.
_objects
+
({
'id'
:
id
,
'meta_type'
:
t
},)
self
.
_setOb
(
id
,
object
)
object
=
self
.
_getOb
(
id
)
object
.
manage_afterAdd
(
object
,
self
)
# Try to give user the local role "Owner".
if
hasattr
(
self
,
'REQUEST'
)
and
hasattr
(
object
,
'__ac_local_roles__'
):
user
=
self
.
REQUEST
[
'AUTHENTICATED_USER'
]
...
...
@@ -213,28 +215,30 @@ class ObjectManager(
object
.
manage_setLocalRoles
(
name
,
[
'Owner'
])
return
id
def
manage_afterAdd
(
self
,
item
,
container
):
for
object
in
self
.
objectValues
():
try
:
s
=
object
.
_p_changed
except
:
s
=
0
object
.
manage_afterAdd
(
item
,
container
)
if
s
is
None
:
object
.
_p_deactivate
()
def
manage_afterClone
(
self
,
item
):
for
object
in
self
.
objectValues
():
try
:
s
=
object
.
_p_changed
except
:
s
=
0
object
.
manage_afterClone
(
item
)
if
s
is
None
:
object
.
_p_deactivate
()
def
manage_beforeDelete
(
self
,
item
,
container
):
for
object
in
self
.
objectValues
():
try
:
s
=
object
.
_p_changed
except
:
s
=
0
object
.
manage_beforeDelete
(
item
,
container
)
if
s
is
None
:
object
.
_p_deactivate
()
def
_delObject
(
self
,
id
,
dp
=
1
):
if
id
==
'acl_users'
:
# Yikes - acl_users is referred to by two names and
# must be treated as a special case! Only get rid of
# __allow_groups__ if it is an instance attribute, to
# avoid deleting the class-default __allow_groups__
# in the top-level application object which is needed
# to allow people to replace the top-level userfolder.
if
hasattr
(
self
,
'__allow_groups__'
)
and
\
self
.
__dict__
.
has_key
(
'__allow_groups__'
):
delattr
(
self
,
'__allow_groups__'
)
# Deletion protocol - when an object is being deleted,
# attempt to call it's _on_delete_object method if
# if has one. The dp flag allows allows callers to
# avoid having the delete protocol triggered (for
# instance when an object is cut and pasted).
if
dp
:
ob
=
self
.
_getOb
(
id
)
if
hasattr
(
ob
,
'_on_delete_object'
)
and
\
callable
(
ob
.
_on_delete_object
):
ob
.
_on_delete_object
()
del
ob
object
=
self
.
_getOb
(
id
)
object
.
manage_beforeDelete
(
object
,
self
)
self
.
_objects
=
tuple
(
filter
(
lambda
i
,
n
=
id
:
i
[
'id'
]
!=
n
,
self
.
_objects
))
self
.
_delOb
(
id
)
...
...
lib/python/OFS/SimpleItem.py
View file @
dc241f2a
...
...
@@ -89,8 +89,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.5
8 1999/06/23 15:27:01
jim Exp $'''
__version__
=
'$Revision: 1.5
8
$'
[
11
:
-
2
]
$Id: SimpleItem.py,v 1.5
9 1999/06/24 19:27:25
jim Exp $'''
__version__
=
'$Revision: 1.5
9
$'
[
11
:
-
2
]
import
regex
,
sys
,
Globals
,
App
.
Management
,
Acquisition
from
webdav.Resource
import
Resource
...
...
@@ -111,13 +111,9 @@ class Item(Base, Resource, CopySource, App.Management.Tabs):
isPrincipiaFolderish
=
0
isTopLevelPrincipiaApplicationObject
=
0
# HACK HACK HACK -- TAKE THIS OUT LATER!!!!
def
_on_delete_object
(
self
):
if
hasattr
(
self
,
'onDeleteObject'
)
and
\
callable
(
self
.
onDeleteObject
):
self
.
onDeleteObject
()
def
manage_afterAdd
(
self
,
item
,
container
):
pass
def
manage_beforeDelete
(
self
,
item
,
container
):
pass
def
manage_afterClone
(
self
,
item
):
pass
# The name of this object and the name used to traverse to thie
# object in a URL:
...
...
lib/python/Products/OFSP/Draft.py
View file @
dc241f2a
...
...
@@ -207,25 +207,18 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
if
REQUEST
:
REQUEST
[
'RESPONSE'
].
redirect
(
REQUEST
[
'URL2'
]
+
'/manage_main'
)
def
_notifyOfCopyTo
(
self
,
container
,
isMove
=
0
):
if
isMove
and
self
.
nonempty
():
raise
'Copy Error'
,
(
"You cannot copy a %s object with <b>unapproved</b> changes.
\
n
"
"You must <b>approve</b> the changes first."
%
self
.
meta_type
)
def
_postCopy
(
self
,
container
,
op
=
0
):
try
:
version
=
self
.
REQUEST
[
'PATH_INFO'
]
l
=
rfind
(
version
,
'/'
)
if
l
>=
0
:
version
=
version
[:
l
]
self
.
_version
=
"%s/%s"
%
(
version
,
self
.
id
)
finally
:
if
0
:
raise
'Copy Error'
,
(
"This object can only be copied through the web.<p>"
)
def
manage_afterClone
(
self
,
item
):
self
.
_version
=
''
def
manage_afterAdd
(
self
,
item
,
container
):
if
not
self
.
_version
:
self
.
_version
=
self
.
absolute_url
(
1
)
def
manage_beforeDelete
(
self
,
item
,
container
):
if
self
.
_nonempty
():
raise
'Version Error'
,
(
'Attempt to %sdelete a non-empty version.<p>'
((
self
is
not
item
)
and
'indirectly '
or
''
))
Globals
.
default__class_init__
(
Draft
)
...
...
lib/python/Products/OFSP/Version.py
View file @
dc241f2a
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Version object"""
__version__
=
'$Revision: 1.3
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
3
$'
[
11
:
-
2
]
import
Globals
,
time
from
AccessControl.Role
import
RoleManager
...
...
@@ -100,10 +100,11 @@ manage_addVersionForm=Globals.HTMLFile('versionAdd', globals())
def
manage_addVersion
(
self
,
id
,
title
,
REQUEST
=
None
):
""" """
self
.
_setObject
(
id
,
Version
(
id
,
title
,
self
,
REQUEST
))
return
self
.
manage_main
(
self
,
REQUEST
)
self
=
self
.
this
()
self
.
_setObject
(
id
,
Version
(
id
,
title
,
REQUEST
))
if
REQUEST
is
not
None
:
REQUEST
[
'RESPONSE'
].
redirect
(
self
.
absolute_url
()
+
'/manage_main'
)
class
Version
(
Persistent
,
Implicit
,
RoleManager
,
Item
):
""" """
...
...
@@ -121,12 +122,11 @@ class Version(Persistent,Implicit,RoleManager,Item):
(
'Save/discard Version changes'
,
(
'save'
,
'discard'
)),
)
def
__init__
(
self
,
id
,
title
,
parent
,
REQUEST
):
cookie
=
''
def
__init__
(
self
,
id
,
title
,
REQUEST
):
self
.
id
=
id
self
.
title
=
title
try
:
parent
=
parent
.
Destination
()
except
:
pass
self
.
cookie
=
self
.
__of__
(
parent
).
absolute_url
(
1
)
manage
=
manage_main
=
Globals
.
HTMLFile
(
'version'
,
globals
())
manage_editForm
=
Globals
.
HTMLFile
(
'versionEdit'
,
globals
())
...
...
@@ -230,11 +230,17 @@ class Version(Persistent,Implicit,RoleManager,Item):
# ZODB 3
return
not
db
.
versionEmpty
(
self
.
cookie
)
def
_notifyOfCopyTo
(
self
,
container
,
isMove
=
0
):
if
isMove
and
self
.
nonempty
():
raise
'Copy Error'
,
(
"You cannot copy a %s object with <b>unsaved</b> changes.
\
n
"
"You must <b>save</b> the changes first."
%
self
.
meta_type
)
def
manage_afterClone
(
self
,
item
):
self
.
cookie
=
''
def
manage_afterAdd
(
self
,
item
,
container
):
if
not
self
.
cookie
:
self
.
cookie
=
self
.
absolute_url
(
1
)
def
manage_beforeDelete
(
self
,
item
,
container
):
if
self
.
_nonempty
():
raise
'Version Error'
,
(
'Attempt to %sdelete a non-empty version.<p>'
((
self
is
not
item
)
and
'indirectly '
or
''
))
lib/python/ZClasses/Property.py
View file @
dc241f2a
...
...
@@ -221,9 +221,10 @@ class ZCommonSheet(OFS.PropertySheets.PropertySheet, OFS.SimpleItem.Item):
return
''
def
_on_delete_object
(
self
):
for
d
in
self
.
_properties
:
self
.
delClassAttr
(
d
[
'id'
])
def
manage_beforeDelete
(
self
,
item
,
container
):
if
self
is
item
:
for
d
in
self
.
_properties
:
self
.
delClassAttr
(
d
[
'id'
])
def
manage_createEditor
(
self
,
id
,
title
=
''
,
REQUEST
=
None
):
"""Create an edit interface for a property sheet
...
...
@@ -305,7 +306,7 @@ class ZInstanceSheet(OFS.PropertySheets.FixedSchema,
):
"Waaa this is too hard"
_Manage_properties_Permission
=
''
_Manage_properties_Permission
=
'
Manage properties
'
_Access_contents_information_Permission
=
'View'
__ac_permissions__
=
(
...
...
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