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
a0a9996b
Commit
a0a9996b
authored
May 24, 2000
by
Shane Hathaway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged the Mount-Dev branch into the main trunk.
parent
e4741a03
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
63 deletions
+113
-63
lib/python/AccessControl/ZopeSecurityPolicy.py
lib/python/AccessControl/ZopeSecurityPolicy.py
+17
-6
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+10
-2
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+30
-20
lib/python/OFS/Moniker.py
lib/python/OFS/Moniker.py
+18
-31
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+5
-2
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+33
-2
No files found.
lib/python/AccessControl/ZopeSecurityPolicy.py
View file @
a0a9996b
...
...
@@ -85,8 +85,8 @@
__doc__
=
'''Define Zope
\
'
s default security policy
$Id: ZopeSecurityPolicy.py,v 1.
2 2000/05/11 18:54:13 jim
Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
$Id: ZopeSecurityPolicy.py,v 1.
3 2000/05/24 20:53:33 shane
Exp $'''
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
SimpleObjectPolicies
_noroles
=
[]
...
...
@@ -157,7 +157,7 @@ class ZopeSecurityPolicy:
if
not
p
:
if
(
containerbase
is
accessedbase
):
raise
'Unauthorized'
,
name
raise
'Unauthorized'
,
cleanupName
(
name
,
value
)
else
:
return
0
...
...
@@ -182,7 +182,8 @@ class ZopeSecurityPolicy:
# get an unacquired!
if
accessed
is
container
:
raise
'Unauthorized'
,
(
'You are not authorized to access <em>%s</em>.'
%
name
)
'You are not authorized to access <em>%s</em>.'
\
%
cleanupName
(
name
,
value
))
return
0
# Proxy roles, which are alot safer now.
...
...
@@ -194,7 +195,8 @@ class ZopeSecurityPolicy:
# Proxy roles actually limit access!
if
accessedbase
is
containerbase
:
raise
'Unauthorized'
,
(
'You are not authorized to access <em>%s</em>.'
%
name
)
'You are not authorized to access <em>%s</em>.'
\
%
cleanupName
(
name
,
value
))
return
0
...
...
@@ -206,7 +208,8 @@ class ZopeSecurityPolicy:
# We don't want someone to acquire if they can't get an unacquired!
if
accessedbase
is
containerbase
:
raise
'Unauthorized'
,
(
'You are not authorized to access <em>%s</em>.'
%
name
)
'You are not authorized to access <em>%s</em>.'
\
%
cleanupName
(
name
,
value
))
return
0
...
...
@@ -215,3 +218,11 @@ class ZopeSecurityPolicy:
if
roles
is
_what_not_even_god_should_do
:
return
0
return
context
.
user
.
has_role
(
roles
,
object
)
def
cleanupName
(
name
,
value
):
# If name is not available, tries to get it from the value.
_name
=
name
if
_name
is
None
and
value
is
not
None
:
try
:
_name
=
value
.
__name__
except
:
pass
return
_name
lib/python/OFS/Application.py
View file @
a0a9996b
...
...
@@ -85,8 +85,8 @@
__doc__
=
'''Application support
$Id: Application.py,v 1.12
4 2000/05/17 00:18:54 jim
Exp $'''
__version__
=
'$Revision: 1.12
4
$'
[
11
:
-
2
]
$Id: Application.py,v 1.12
5 2000/05/24 20:53:34 shane
Exp $'''
__version__
=
'$Revision: 1.12
5
$'
[
11
:
-
2
]
import
Globals
,
Folder
,
os
,
sys
,
App
.
Product
,
App
.
ProductRegistry
,
misc_
import
time
,
traceback
,
os
,
string
,
Products
...
...
@@ -283,6 +283,14 @@ class Application(Globals.ApplicationDefaultPermissions,
if
relative
:
return
''
return
self
.
aq_acquire
(
'REQUEST'
).
script
def
getPhysicalPath
(
self
):
'''Returns a path that can be used to access this object again
later, for example in a copy/paste operation. Designed to
be used with getPhysicalRoot().
'''
# We're at the base of the path.
return
''
def
getPhysicalRoot
(
self
):
return
self
class
Expired
(
Globals
.
Persistent
):
...
...
lib/python/OFS/CopySupport.py
View file @
a0a9996b
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.5
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
1
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
from
marshal
import
loads
,
dumps
...
...
@@ -118,7 +118,7 @@ class CopyContainer(ExtensionClass.Base):
def
manage_CopyContainerFirstItem
(
self
,
REQUEST
):
return
self
.
_getOb
(
REQUEST
[
'ids'
][
0
])
return
self
.
_getOb
(
REQUEST
[
'ids'
][
0
])
def
manage_CopyContainerAllItems
(
self
,
REQUEST
):
return
map
(
lambda
i
,
s
=
self
:
s
.
_getOb
(
i
),
tuple
(
REQUEST
[
'ids'
]))
...
...
@@ -133,7 +133,7 @@ class CopyContainer(ExtensionClass.Base):
if
not
ob
.
cb_isMoveable
():
raise
CopyError
,
eNotSupported
%
id
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
(
m
.
jar
,
m
.
ids
))
oblist
.
append
(
m
.
dump
(
))
cp
=
(
1
,
oblist
)
cp
=
_cb_encode
(
cp
)
if
REQUEST
is
not
None
:
...
...
@@ -152,7 +152,7 @@ class CopyContainer(ExtensionClass.Base):
if
not
ob
.
cb_isCopyable
():
raise
CopyError
,
eNotSupported
%
id
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
(
m
.
jar
,
m
.
ids
))
oblist
.
append
(
m
.
dump
(
))
cp
=
(
0
,
oblist
)
cp
=
_cb_encode
(
cp
)
if
REQUEST
is
not
None
:
...
...
@@ -193,12 +193,12 @@ class CopyContainer(ExtensionClass.Base):
except
:
raise
CopyError
,
eInvalid
oblist
=
[]
m
=
Moniker
.
Moniker
()
op
=
cp
[
0
]
for
j
,
d
in
cp
[
1
]:
m
.
jar
=
j
m
.
ids
=
d
try
:
ob
=
m
.
bind
(
self
.
_p_jar
)
app
=
self
.
getPhysicalRoot
()
for
mdata
in
cp
[
1
]:
m
=
Moniker
.
loadMoniker
(
mdata
)
try
:
ob
=
m
.
bind
(
app
)
except
:
raise
CopyError
,
eNotFound
self
.
_verifyObjectPaste
(
ob
,
REQUEST
)
oblist
.
append
(
ob
)
...
...
@@ -207,7 +207,12 @@ class CopyContainer(ExtensionClass.Base):
# Copy operation
for
ob
in
oblist
:
if
not
ob
.
cb_isCopyable
():
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
0
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'Copy Error'
,
message
=
sys
.
exc_value
,
action
=
'manage_main'
)
ob
=
ob
.
_getCopy
(
self
)
ob
.
manage_afterClone
(
ob
)
id
=
self
.
_get_id
(
absattr
(
ob
.
id
))
...
...
@@ -224,6 +229,11 @@ class CopyContainer(ExtensionClass.Base):
id
=
absattr
(
ob
.
id
)
if
not
ob
.
cb_isMoveable
():
raise
CopyError
,
eNotSupported
%
id
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
1
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'Move Error'
,
message
=
sys
.
exc_value
,
action
=
'manage_main'
)
if
not
sanity_check
(
self
,
ob
):
raise
CopyError
,
'This object cannot be pasted into itself'
ob
.
aq_parent
.
_delObject
(
id
)
...
...
@@ -299,7 +309,7 @@ class CopyContainer(ExtensionClass.Base):
self
.
_verifyObjectPaste
(
ob
,
REQUEST
)
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
0
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'
Renam
e Error'
,
title
=
'
Clon
e Error'
,
message
=
sys
.
exc_value
,
action
=
'manage_main'
)
ob
=
ob
.
_getCopy
(
self
)
...
...
@@ -320,12 +330,11 @@ class CopyContainer(ExtensionClass.Base):
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
except
:
return
[]
oblist
=
[]
m
=
Moniker
.
Moniker
()
op
=
cp
[
0
]
for
j
,
d
in
cp
[
1
]:
m
.
jar
=
j
m
.
ids
=
d
oblist
.
append
(
m
.
bind
(
self
.
_p_jar
))
app
=
self
.
getPhysicalRoot
()
for
mdata
in
cp
[
1
]:
m
=
Moniker
.
loadMoniker
(
mdata
)
oblist
.
append
(
m
.
bind
(
app
))
return
oblist
validClipData
=
cb_dataValid
...
...
@@ -355,11 +364,12 @@ class CopyContainer(ExtensionClass.Base):
REQUEST
=
getattr
(
self
,
'REQUEST'
,
None
)
if
method_name
is
not
None
:
meth
=
self
.
unrestrictedTraverse
(
method_name
)
if
getSecurityManager
().
validateValue
(
meth
):
return
# Ensure the user is allowed to access the object on the
# clipboard.
if
getSecurityManager
().
validateValue
(
ob
):
return
raise
CopyError
,
MessageDialog
(
title
=
'Not Supported'
,
...
...
lib/python/OFS/Moniker.py
View file @
a0a9996b
...
...
@@ -90,53 +90,40 @@
and aquisition relationships via a simple interface.
"""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
Globals
import
string
class
Moniker
:
"""An object moniker is an intelligent reference to a
persistent object. A moniker can be turned back into
a real object that retains its correct version context
and aquisition relationships via a simple interface."""
and a
c
quisition relationships via a simple interface."""
def
__init__
(
self
,
ob
=
None
):
if
ob
is
None
:
return
self
.
jar
=
ob
.
_p_jar
.
getVersion
()
self
.
ids
=
[]
while
1
:
if
not
hasattr
(
ob
,
'_p_oid'
):
break
self
.
ids
.
append
(
ob
.
_p_oid
)
if
not
hasattr
(
ob
,
'aq_parent'
):
break
ob
=
ob
.
aq_parent
self
.
ids
.
reverse
()
self
.
idpath
=
ob
.
getPhysicalPath
()
def
id
(
self
):
return
absattr
(
self
.
bind
().
id
)
def
mtype
(
self
):
return
absattr
(
self
.
bind
().
meta_type
)
def
bind
(
self
,
jar
):
"Return the real object named by this moniker"
ob
=
None
for
n
in
self
.
ids
:
o
=
jar
[
n
]
if
ob
is
not
None
:
o
=
o
.
__of__
(
ob
)
ob
=
o
def
bind
(
self
,
app
):
"Returns the real object named by this moniker"
ob
=
app
.
unrestrictedTraverse
(
self
.
idpath
)
return
ob
def
exact
(
self
,
ob
):
"""Check against another moniker to see if it
refers to the exact same object in the exact
same acquisition context."""
return
self
.
jar
==
ob
.
jar
and
self
.
ids
==
ob
.
ids
def
dump
(
self
):
'''Returns an object which can be reconstituted by
loadMoniker(). Result must be compatible with marshal.dump().
'''
return
self
.
idpath
def
loadMoniker
(
data
):
'''Re-creates a Moniker object from the given data which had been
generated by Moniker.dump().'''
m
=
Moniker
()
m
.
idpath
=
data
return
m
def
absattr
(
attr
):
if
callable
(
attr
):
return
attr
()
...
...
lib/python/OFS/ObjectManager.py
View file @
a0a9996b
...
...
@@ -84,9 +84,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.9
3 2000/05/17 20:56:27 brian
Exp $"""
$Id: ObjectManager.py,v 1.9
4 2000/05/24 20:53:34 shane
Exp $"""
__version__
=
'$Revision: 1.9
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.9
4
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
ts_regex
,
Products
...
...
@@ -295,6 +295,9 @@ class ObjectManager(
pass
self
.
_objects
=
tuple
(
filter
(
lambda
i
,
n
=
id
:
i
[
'id'
]
!=
n
,
self
.
_objects
))
self
.
_delOb
(
id
)
# Indicate to the object that it has been deleted.
# Necessary for mount points.
object
.
_v__object_deleted__
=
1
def
objectIds
(
self
,
spec
=
None
):
"""Returns a list of subobject ids of the current object.
...
...
lib/python/OFS/SimpleItem.py
View file @
a0a9996b
...
...
@@ -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.7
0 2000/05/17 18:50:29 brian
Exp $'''
__version__
=
'$Revision: 1.7
0
$'
[
11
:
-
2
]
$Id: SimpleItem.py,v 1.7
1 2000/05/24 20:53:34 shane
Exp $'''
__version__
=
'$Revision: 1.7
1
$'
[
11
:
-
2
]
import
regex
,
sys
,
Globals
,
App
.
Management
,
Acquisition
,
App
.
Undo
import
AccessControl.Role
,
AccessControl
.
Owned
,
App
.
Common
...
...
@@ -347,6 +347,20 @@ class Item(Base, Resource, CopySource, App.Management.Tabs,
return
id
def
getPhysicalPath
(
self
):
'''Returns a path that can be used to access this object again
later, for example in a copy/paste operation. getPhysicalRoot()
and getPhysicalPath() are designed to operate together.
'''
id
=
quote
(
self
.
id
)
p
=
getattr
(
self
,
'aq_inner'
,
None
)
if
p
is
not
None
:
url
=
p
.
aq_parent
.
getPhysicalPath
()
if
url
:
id
=
url
+
'/'
+
id
return
id
unrestrictedTraverse__roles__
=
()
def
unrestrictedTraverse
(
self
,
path
,
default
=
_marker
):
...
...
@@ -373,6 +387,9 @@ class Item(Base, Resource, CopySource, App.Management.Tabs,
if
o
is
not
M
:
object
=
o
continue
if
name
[
0
]
==
'_'
:
# Never allowed in a URL.
raise
'NotFound'
,
name
t
=
get
(
object
,
'__bobo_traverse__'
,
N
)
if
t
is
not
N
:
...
...
@@ -419,6 +436,20 @@ class Item_w__name__(Item):
return
id
def
getPhysicalPath
(
self
):
'''Returns a path that can be used to access this object again
later, for example in a copy/paste operation. getPhysicalRoot()
and getPhysicalPath() are designed to operate together.
'''
id
=
quote
(
self
.
__name__
)
p
=
getattr
(
self
,
'aq_inner'
,
None
)
if
p
is
not
None
:
url
=
p
.
aq_parent
.
getPhysicalPath
()
if
url
:
id
=
url
+
'/'
+
id
return
id
def
format_exception
(
etype
,
value
,
tb
,
limit
=
None
):
import
traceback
result
=
[
'Traceback (innermost last):'
]
...
...
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