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
56ea1fc9
Commit
56ea1fc9
authored
Sep 05, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented getId() in SimpleItem; got rid of direct refs to object.id
in OFS package
parent
7371b1c6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
78 deletions
+87
-78
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+5
-5
lib/python/OFS/DTMLDocument.py
lib/python/OFS/DTMLDocument.py
+2
-2
lib/python/OFS/DTMLMethod.py
lib/python/OFS/DTMLMethod.py
+3
-3
lib/python/OFS/FindSupport.py
lib/python/OFS/FindSupport.py
+3
-3
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+40
-39
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+9
-6
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+22
-17
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+3
-3
No files found.
lib/python/OFS/CopySupport.py
View file @
56ea1fc9
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.5
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
8
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
from
marshal
import
loads
,
dumps
...
...
@@ -207,7 +207,7 @@ class CopyContainer(ExtensionClass.Base):
# Copy operation
for
ob
in
oblist
:
if
not
ob
.
cb_isCopyable
():
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
raise
CopyError
,
eNotSupported
%
ob
.
getId
(
)
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
0
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'Copy Error'
,
...
...
@@ -215,7 +215,7 @@ class CopyContainer(ExtensionClass.Base):
action
=
'manage_main'
)
ob
=
ob
.
_getCopy
(
self
)
ob
.
manage_afterClone
(
ob
)
id
=
self
.
_get_id
(
absattr
(
ob
.
id
))
id
=
self
.
_get_id
(
ob
.
getId
(
))
ob
.
_setId
(
id
)
self
.
_setObject
(
id
,
ob
)
...
...
@@ -226,7 +226,7 @@ class CopyContainer(ExtensionClass.Base):
if
op
==
1
:
# Move operation
for
ob
in
oblist
:
id
=
absattr
(
ob
.
id
)
id
=
ob
.
getId
(
)
if
not
ob
.
cb_isMoveable
():
raise
CopyError
,
eNotSupported
%
id
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
1
)
...
...
@@ -312,7 +312,7 @@ class CopyContainer(ExtensionClass.Base):
def
manage_clone
(
self
,
ob
,
id
,
REQUEST
=
None
):
# Clone an object, creating a new object with the given id.
if
not
ob
.
cb_isCopyable
():
raise
CopyError
,
eNotSupported
%
absattr
(
ob
.
id
)
raise
CopyError
,
eNotSupported
%
ob
.
getId
()
try
:
self
.
_checkId
(
id
)
except
:
raise
CopyError
,
MessageDialog
(
title
=
'Invalid Id'
,
...
...
lib/python/OFS/DTMLDocument.py
View file @
56ea1fc9
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""DTML Document objects."""
__version__
=
'$Revision: 1.3
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
9
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
ZPublisher.Converters
import
type_converters
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
...
...
@@ -158,7 +158,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
def
__call__
(
self
,
client
=
None
,
REQUEST
=
{},
RESPONSE
=
None
,
**
kw
):
"""Render the document given a client object, REQUEST mapping,
Response, and key word arguments."""
kw
[
'document_id'
]
=
self
.
id
kw
[
'document_id'
]
=
self
.
getId
()
kw
[
'document_title'
]
=
self
.
title
if
hasattr
(
self
,
'aq_explicit'
):
bself
=
self
.
aq_explicit
...
...
lib/python/OFS/DTMLMethod.py
View file @
56ea1fc9
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""DTML Method objects."""
__version__
=
'$Revision: 1.5
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
4
$'
[
11
:
-
2
]
import
History
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
...
...
@@ -156,7 +156,7 @@ class DTMLMethod(HTML, Acquisition.Implicit, RoleManager,
def
__call__
(
self
,
client
=
None
,
REQUEST
=
{},
RESPONSE
=
None
,
**
kw
):
"""Render the document given a client object, REQUEST mapping,
Response, and key word arguments."""
kw
[
'document_id'
]
=
self
.
id
kw
[
'document_id'
]
=
self
.
getId
()
kw
[
'document_title'
]
=
self
.
title
security
=
getSecurityManager
()
...
...
@@ -180,7 +180,7 @@ class DTMLMethod(HTML, Acquisition.Implicit, RoleManager,
if
self
.
__dict__
.
has_key
(
'content_type'
):
c
=
self
.
content_type
else
:
c
,
e
=
guess_content_type
(
self
.
__name__
,
r
)
c
,
e
=
guess_content_type
(
self
.
getId
()
,
r
)
RESPONSE
.
setHeader
(
'Content-Type'
,
c
)
return
decapitate
(
r
,
RESPONSE
)
...
...
lib/python/OFS/FindSupport.py
View file @
56ea1fc9
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Find support"""
__version__
=
'$Revision: 1.2
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
import
sys
,
os
,
string
,
time
,
Globals
,
ExtensionClass
...
...
@@ -170,7 +170,7 @@ class FindSupport(ExtensionClass.Base):
else
:
bs
=
ob
if
(
(
not
obj_ids
or
absattr
(
bs
.
id
)
in
obj_ids
)
(
not
obj_ids
or
absattr
(
bs
.
getId
()
)
in
obj_ids
)
and
(
not
obj_metatypes
or
(
hasattr
(
bs
,
'meta_type'
)
and
bs
.
meta_type
in
obj_metatypes
))
...
...
@@ -262,7 +262,7 @@ class FindSupport(ExtensionClass.Base):
else
:
bs
=
ob
if
(
(
not
obj_ids
or
absattr
(
bs
.
id
)
in
obj_ids
)
(
not
obj_ids
or
absattr
(
bs
.
getId
()
)
in
obj_ids
)
and
(
not
obj_metatypes
or
(
hasattr
(
bs
,
'meta_type'
)
and
bs
.
meta_type
in
obj_metatypes
))
...
...
lib/python/OFS/ObjectManager.py
View file @
56ea1fc9
...
...
@@ -84,9 +84,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.10
8 2000/08/17 20:17:24 shane
Exp $"""
$Id: ObjectManager.py,v 1.10
9 2000/09/05 20:52:47 brian
Exp $"""
__version__
=
'$Revision: 1.10
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.10
9
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
ts_regex
,
Products
...
...
@@ -483,8 +483,7 @@ class ObjectManager(
RESPONSE
=
None
):
"""Exports an object to a file and returns that file."""
if
not
id
:
id
=
self
.
id
if
callable
(
id
):
id
=
id
()
id
=
self
.
getId
()
ob
=
self
else
:
ob
=
self
.
_getOb
(
id
)
...
...
@@ -530,8 +529,7 @@ class ObjectManager(
ob
=
connection
.
importFile
(
file
,
customImporters
=
customImporters
)
if
REQUEST
:
self
.
_verifyObjectPaste
(
ob
,
validate_src
=
0
)
id
=
ob
.
id
if
hasattr
(
id
,
'im_func'
):
id
=
id
()
id
=
ob
.
getId
()
self
.
_setObject
(
id
,
ob
,
set_owner
=
set_owner
)
# try to make ownership implicit if possible in the context
...
...
@@ -619,38 +617,41 @@ class ObjectManager(
Globals
.
default__class_init__
(
ObjectManager
)
class
PUTer
(
Acquisition
.
Explicit
):
"""Class to support the HTTP PUT protocol."""
def
__init__
(
self
,
parent
,
id
):
self
.
id
=
id
self
.
__parent__
=
parent
self
.
__roles__
=
parent
.
PUT__roles__
## This isnt used anymore - NullResource now handles PUTs.
## class PUTer(Acquisition.Explicit):
## """Class to support the HTTP PUT protocol."""
## def __init__(self, parent, id):
## self.id=id
## self.__parent__=parent
## self.__roles__ =parent.PUT__roles__
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""Adds a document, image or file to the folder when a PUT
request is received."""
name
=
self
.
id
type
=
REQUEST
.
get_header
(
'content-type'
,
None
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
if
type
is
None
:
type
,
enc
=
mimetypes
.
guess_type
(
name
)
if
type
is
None
:
if
content_types
.
find_binary
(
body
)
>=
0
:
type
=
'application/octet-stream'
else
:
type
=
content_types
.
text_type
(
body
)
type
=
lower
(
type
)
if
type
in
(
'text/html'
,
'text/xml'
,
'text/plain'
):
self
.
__parent__
.
manage_addDTMLDocument
(
name
,
''
,
body
)
elif
type
[:
6
]
==
'image/'
:
ob
=
Image
(
name
,
''
,
body
,
content_type
=
type
)
self
.
__parent__
.
_setObject
(
name
,
ob
)
else
:
ob
=
File
(
name
,
''
,
body
,
content_type
=
type
)
self
.
__parent__
.
_setObject
(
name
,
ob
)
RESPONSE
.
setStatus
(
201
)
RESPONSE
.
setBody
(
''
)
return
RESPONSE
def
__str__
(
self
):
return
self
.
id
##
def PUT(self, REQUEST, RESPONSE):
##
"""Adds a document, image or file to the folder when a PUT
##
request is received."""
##
name=self.id
##
type=REQUEST.get_header('content-type', None)
##
body=REQUEST.get('BODY', '')
##
if type is None:
##
type, enc=mimetypes.guess_type(name)
##
if type is None:
##
if content_types.find_binary(body) >= 0:
##
type='application/octet-stream'
##
else: type=content_types.text_type(body)
##
type=lower(type)
##
if type in ('text/html', 'text/xml', 'text/plain'):
##
self.__parent__.manage_addDTMLDocument(name, '', body)
##
elif type[:6]=='image/':
##
ob=Image(name, '', body, content_type=type)
##
self.__parent__._setObject(name, ob)
##
else:
##
ob=File(name, '', body, content_type=type)
##
self.__parent__._setObject(name, ob)
##
RESPONSE.setStatus(201)
##
RESPONSE.setBody('')
##
return RESPONSE
##
def __str__(self):
##
return self.id
lib/python/OFS/PropertySheets.py
View file @
56ea1fc9
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.5
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
,
Globals
from
ZPublisher.Converters
import
type_converters
...
...
@@ -110,7 +110,7 @@ class View(App.Management.Tabs, Base):
'''
RESPONSE
.
redirect
(
URL1
+
'/manage'
)
def
tpURL
(
self
):
return
self
.
id
def
tpURL
(
self
):
return
self
.
getId
()
def
manage_options
(
self
):
"""Return a manage option data structure for me instance
...
...
@@ -188,7 +188,10 @@ class PropertySheet(Traversable, Persistent, Implicit):
# space identifier.
self
.
id
=
id
self
.
_md
=
md
or
{}
def
getId
(
self
):
return
self
.
id
def
xml_namespace
(
self
):
# Return a namespace string usable as an xml namespace
# for this property set.
...
...
@@ -630,7 +633,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
def
__bobo_traverse__
(
self
,
REQUEST
,
name
=
None
):
for
propset
in
self
.
__propsets__
():
if
propset
.
id
==
name
:
if
propset
.
getId
()
==
name
:
return
propset
.
__of__
(
self
)
return
getattr
(
self
,
name
)
...
...
@@ -653,7 +656,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
def
get
(
self
,
name
,
default
=
None
):
for
propset
in
self
.
__propsets__
():
if
propset
.
id
==
name
or
propset
.
xml_namespace
()
==
name
:
if
propset
.
getId
()
==
name
or
propset
.
xml_namespace
()
==
name
:
return
propset
.
__of__
(
self
)
return
default
...
...
@@ -672,7 +675,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
def
delPropertySheet
(
self
,
name
):
result
=
[]
for
propset
in
self
.
aq_parent
.
__propsets__
:
if
propset
.
id
!=
name
and
propset
.
xml_namespace
()
!=
name
:
if
propset
.
getId
()
!=
name
and
propset
.
xml_namespace
()
!=
name
:
result
.
append
(
propset
)
self
.
parent
.
__propsets__
=
tuple
(
result
)
...
...
lib/python/OFS/SimpleItem.py
View file @
56ea1fc9
...
...
@@ -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
8 2000/06/12 19:49:48 shane
Exp $'''
__version__
=
'$Revision: 1.7
8
$'
[
11
:
-
2
]
$Id: SimpleItem.py,v 1.7
9 2000/09/05 20:52:47 brian
Exp $'''
__version__
=
'$Revision: 1.7
9
$'
[
11
:
-
2
]
import
regex
,
sys
,
Globals
,
App
.
Management
,
Acquisition
,
App
.
Undo
import
AccessControl.Role
,
AccessControl
.
Owned
,
App
.
Common
...
...
@@ -123,12 +123,25 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
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:
# Direct use of the 'id' attribute is deprecated - use getId()
id
=
''
getId__roles__
=
None
def
getId
(
self
):
"""Return the id of the object as a string. This method
should be used in preference to accessing an id attribute
of an object directly. The getId method is public."""
name
=
getattr
(
self
,
'id'
,
None
)
if
callable
(
name
):
return
name
()
if
name
is
not
None
:
return
name
if
hasattr
(
self
,
'__name__'
):
return
self
.
__name__
raise
AttributeError
,
'This object has no id'
# Alias id to __name__, which will make tracebacks a good bit nicer:
__name__
=
ComputedAttribute
(
lambda
self
:
self
.
id
)
__name__
=
ComputedAttribute
(
lambda
self
:
self
.
getId
()
)
# Name, relative to SOFTWARE_URL of icon used to display item
# in folder listings.
...
...
@@ -164,10 +177,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
if
callable
(
title
):
title
=
title
()
if
title
:
return
title
id
=
self
.
id
if
callable
(
id
):
id
=
id
()
return
id
return
self
.
getId
()
def
title_and_id
(
self
):
"""
...
...
@@ -178,9 +188,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
title
=
self
.
title
if
callable
(
title
):
title
=
title
()
id
=
self
.
id
if
callable
(
id
):
id
=
id
()
id
=
self
.
getId
()
return
title
and
(
"%s (%s)"
%
(
title
,
id
))
or
id
def
this
(
self
):
...
...
@@ -189,9 +197,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
def
tpURL
(
self
):
# My URL as used by tree tag
url
=
self
.
id
if
hasattr
(
url
,
'im_func'
):
url
=
url
()
return
url
return
self
.
getId
()
def
tpValues
(
self
):
# My sub-objects as used by the tree tag
...
...
@@ -326,8 +332,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
ob
=
ob
.
aq_parent
stat
=
marshal
.
loads
(
self
.
manage_FTPstat
(
REQUEST
))
if
callable
(
self
.
id
):
id
=
self
.
id
()
else
:
id
=
self
.
id
id
=
self
.
getId
()
return
marshal
.
dumps
((
id
,
stat
))
def
__len__
(
self
):
...
...
lib/python/OFS/Traversable.py
View file @
56ea1fc9
...
...
@@ -84,8 +84,8 @@
##############################################################################
'''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.
4 2000/08/15 17:52:53 ev
an Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
$Id: Traversable.py,v 1.
5 2000/09/05 20:52:47 bri
an Exp $'''
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
Acquisition
...
...
@@ -128,7 +128,7 @@ class Traversable:
later, for example in a copy/paste operation. getPhysicalRoot()
and getPhysicalPath() are designed to operate together.
'''
path
=
(
self
.
id
,)
path
=
(
self
.
getId
()
,)
p
=
getattr
(
self
,
'aq_inner'
,
None
)
if
p
is
not
None
:
...
...
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