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
0f6094d8
Commit
0f6094d8
authored
Nov 26, 1998
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more doc strings and converted some comments to doc strings.
parent
c41229bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
44 deletions
+80
-44
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+16
-10
lib/python/OFS/Document.py
lib/python/OFS/Document.py
+10
-6
lib/python/OFS/Folder.py
lib/python/OFS/Folder.py
+15
-6
lib/python/OFS/Moniker.py
lib/python/OFS/Moniker.py
+13
-6
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+26
-16
No files found.
lib/python/OFS/CopySupport.py
View file @
0f6094d8
__doc__
=
"""Copy interface"""
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
from
marshal
import
loads
,
dumps
from
marshal
import
loads
,
dumps
...
@@ -11,7 +11,7 @@ from App.Dialogs import MessageDialog
...
@@ -11,7 +11,7 @@ from App.Dialogs import MessageDialog
CopyError
=
'Copy Error'
CopyError
=
'Copy Error'
class
CopyContainer
:
class
CopyContainer
:
# Interface for containerish objects which allow cut/copy/paste
"""Interface for containerish objects which allow cut/copy/paste"""
def
manage_cutObjects
(
self
,
ids
,
REQUEST
=
None
):
def
manage_cutObjects
(
self
,
ids
,
REQUEST
=
None
):
"""Put a reference to the objects named in ids in the clip board"""
"""Put a reference to the objects named in ids in the clip board"""
...
@@ -176,12 +176,13 @@ class CopyContainer:
...
@@ -176,12 +176,13 @@ class CopyContainer:
return
ob
return
ob
def
cb_dataValid
(
self
):
def
cb_dataValid
(
self
):
# Return true if clipboard data seems valid.
"Return true if clipboard data seems valid."
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
except
:
return
0
except
:
return
0
return
1
return
1
def
cb_dataItems
(
self
):
def
cb_dataItems
(
self
):
"List of objects in the clip board"
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
except
:
return
[]
except
:
return
[]
oblist
=
[]
oblist
=
[]
...
@@ -252,17 +253,17 @@ Globals.default__class_init__(CopyContainer)
...
@@ -252,17 +253,17 @@ Globals.default__class_init__(CopyContainer)
class
CopySource
:
class
CopySource
:
# Interface for objects which allow themselves to be copied.
"""Interface for objects which allow themselves to be copied."""
def
_canCopy
(
self
,
op
=
0
):
def
_canCopy
(
self
,
op
=
0
):
#
Called to make sure this object is copyable. The op var
"""
Called to make sure this object is copyable. The op var
# is 0 for a copy, 1 for a move.
is 0 for a copy, 1 for a move."""
return
1
return
1
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
#
Overide this to be pickly about where you go! If you dont
"""
Overide this to be pickly about where you go! If you dont
#
want to go there, raise an exception. The op variable is
want to go there, raise an exception. The op variable is
# 0 for a copy, 1 for a move.
0 for a copy, 1 for a move."""
pass
pass
def
_getCopy
(
self
,
container
):
def
_getCopy
(
self
,
container
):
...
@@ -284,13 +285,15 @@ class CopySource:
...
@@ -284,13 +285,15 @@ class CopySource:
self
.
id
=
id
self
.
id
=
id
def
cb_isCopyable
(
self
):
def
cb_isCopyable
(
self
):
if
not
(
hasattr
(
self
,
'_canCopy'
)
and
self
.
_canCopy
(
0
)):
"""Is object copyable? Returns 0 or 1"""
if
not
(
hasattr
(
self
,
'_canCopy'
)
and
self
.
_canCopy
(
0
)):
return
0
return
0
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
return
0
return
0
return
1
return
1
def
cb_isMoveable
(
self
):
def
cb_isMoveable
(
self
):
"""Is object moveable? Returns 0 or 1"""
if
not
(
hasattr
(
self
,
'_canCopy'
)
and
self
.
_canCopy
(
1
)):
if
not
(
hasattr
(
self
,
'_canCopy'
)
and
self
.
_canCopy
(
1
)):
return
0
return
0
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
...
@@ -395,6 +398,9 @@ eNotSupported=fMessageDialog(
...
@@ -395,6 +398,9 @@ eNotSupported=fMessageDialog(
##############################################################################
##############################################################################
#
#
# $Log: CopySupport.py,v $
# $Log: CopySupport.py,v $
# Revision 1.23 1998/11/26 21:11:35 amos
# Added more doc strings and converted some comments to doc strings.
#
# Revision 1.22 1998/10/07 15:21:13 jim
# Revision 1.22 1998/10/07 15:21:13 jim
# Rearranged order of operations to make move and copy consistent.
# Rearranged order of operations to make move and copy consistent.
# In particular, copy or moved object has new ID *before* it gets
# In particular, copy or moved object has new ID *before* it gets
...
...
lib/python/OFS/Document.py
View file @
0f6094d8
"""Document object"""
"""Document object"""
__version__
=
'$Revision: 1.6
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.6
8
$'
[
11
:
-
2
]
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
...
@@ -13,7 +13,8 @@ from DocumentTemplate.DT_Util import cDocument
...
@@ -13,7 +13,8 @@ from DocumentTemplate.DT_Util import cDocument
class
Document
(
cDocument
,
HTML
,
Explicit
,
class
Document
(
cDocument
,
HTML
,
Explicit
,
RoleManager
,
Item_w__name__
,
RoleManager
,
Item_w__name__
,
):
):
""" """
"""Document object. Basically a DocumentTemplate.HTML object
which operates as a Principia object."""
meta_type
=
'Document'
meta_type
=
'Document'
icon
=
'p_/doc'
icon
=
'p_/doc'
_proxy_roles
=
()
_proxy_roles
=
()
...
@@ -67,7 +68,8 @@ class Document(cDocument, HTML, Explicit,
...
@@ -67,7 +68,8 @@ class Document(cDocument, HTML, Explicit,
def
__call__
(
self
,
client
=
None
,
REQUEST
=
{},
RESPONSE
=
None
,
**
kw
):
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
.
id
kw
[
'document_title'
]
=
self
.
title
kw
[
'document_title'
]
=
self
.
title
if
client
is
None
:
if
client
is
None
:
...
@@ -179,7 +181,7 @@ class Document(cDocument, HTML, Explicit,
...
@@ -179,7 +181,7 @@ class Document(cDocument, HTML, Explicit,
def
PUT
(
self
,
BODY
,
REQUEST
):
def
PUT
(
self
,
BODY
,
REQUEST
):
"""
"""
replaces the contents of the document with the BODY of an HTTP PUT request.
replaces the contents of the document with the BODY of an HTTP PUT request.
"""
"""
self
.
_validateProxy
(
REQUEST
)
self
.
_validateProxy
(
REQUEST
)
self
.
munge
(
BODY
)
self
.
munge
(
BODY
)
...
@@ -215,7 +217,9 @@ class Document(cDocument, HTML, Explicit,
...
@@ -215,7 +217,9 @@ class Document(cDocument, HTML, Explicit,
message
=
'Your changes have been saved'
,
message
=
'Your changes have been saved'
,
action
=
'manage_main'
)
action
=
'manage_main'
)
def
PrincipiaSearchSource
(
self
):
return
self
.
read
()
def
PrincipiaSearchSource
(
self
):
"Support for searching - the document's contents are searched."
return
self
.
read
()
default_html
=
"""<!--#var standard_html_header-->
default_html
=
"""<!--#var standard_html_header-->
<H2><!--#var title_or_id--> <!--#var document_title--></H2>
<H2><!--#var title_or_id--> <!--#var document_title--></H2>
...
@@ -243,7 +247,7 @@ def manage_addDocument(self, id, title='',file='', REQUEST=None, submit=None):
...
@@ -243,7 +247,7 @@ def manage_addDocument(self, id, title='',file='', REQUEST=None, submit=None):
return
''
return
''
class
DocumentHandler
:
class
DocumentHandler
:
"""
"""
"""
Mixin class for objects that can contain Documents.
"""
def
documentIds
(
self
):
def
documentIds
(
self
):
t
=
[]
t
=
[]
...
...
lib/python/OFS/Folder.py
View file @
0f6094d8
"""Folder object
"""Folder object
$Id: Folder.py,v 1.53 1998/08/26 18:33:44 brian Exp $"""
Folders are the basic container objects and are analogous to directories.
__version__
=
'$Revision: 1.53 $'
[
11
:
-
2
]
$Id: Folder.py,v 1.54 1998/11/26 21:11:35 amos Exp $"""
__version__
=
'$Revision: 1.54 $'
[
11
:
-
2
]
from
Globals
import
HTMLFile
from
Globals
import
HTMLFile
...
@@ -97,6 +99,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
...
@@ -97,6 +99,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
manage_addObject__roles__
=
None
manage_addObject__roles__
=
None
def
tpValues
(
self
):
def
tpValues
(
self
):
"""Returns a list of the folder's sub-folders, used by tree tag."""
r
=
[]
r
=
[]
if
hasattr
(
self
.
aq_base
,
'tree_ids'
):
if
hasattr
(
self
.
aq_base
,
'tree_ids'
):
for
id
in
self
.
aq_base
.
tree_ids
:
for
id
in
self
.
aq_base
.
tree_ids
:
...
@@ -134,7 +137,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
...
@@ -134,7 +137,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
# The Following methods are short-term measures to get Paul off my back;)
# The Following methods are short-term measures to get Paul off my back;)
def
manage_exportHack
(
self
,
id
=
None
):
def
manage_exportHack
(
self
,
id
=
None
):
" "
"""Exports a folder and its contents to /var/export.bbe
This file can later be imported by using manage_importHack"""
if
id
is
None
:
o
=
self
if
id
is
None
:
o
=
self
else
:
o
=
getattr
(
self
.
o
)
else
:
o
=
getattr
(
self
.
o
)
f
=
Globals
.
data_dir
+
'/export.bbe'
f
=
Globals
.
data_dir
+
'/export.bbe'
...
@@ -142,7 +146,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
...
@@ -142,7 +146,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
return
f
return
f
def
manage_importHack
(
self
,
REQUEST
=
None
):
def
manage_importHack
(
self
,
REQUEST
=
None
):
"
"
"
Imports a previously exported object from /var/export.bbe
"
f
=
Globals
.
data_dir
+
'/export.bbe'
f
=
Globals
.
data_dir
+
'/export.bbe'
o
=
self
.
_p_jar
.
import_file
(
f
)
o
=
self
.
_p_jar
.
import_file
(
f
)
id
=
o
.
id
id
=
o
.
id
...
@@ -151,14 +155,16 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
...
@@ -151,14 +155,16 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
return
'OK, I imported %s'
%
id
return
'OK, I imported %s'
%
id
class
PUTer
:
class
PUTer
:
""" """
"""Class to support the HTTP PUT protocol."""
def
__init__
(
self
,
parent
,
key
):
def
__init__
(
self
,
parent
,
key
):
self
.
_parent
=
parent
self
.
_parent
=
parent
self
.
_key
=
key
self
.
_key
=
key
self
.
__roles__
=
parent
.
PUT__roles__
self
.
__roles__
=
parent
.
PUT__roles__
def
PUT
(
self
,
REQUEST
,
BODY
):
def
PUT
(
self
,
REQUEST
,
BODY
):
""" """
"""Adds a document, image or file to the folder when a PUT
request is received."""
name
=
self
.
_key
name
=
self
.
_key
try
:
type
=
REQUEST
[
'CONTENT_TYPE'
]
try
:
type
=
REQUEST
[
'CONTENT_TYPE'
]
except
KeyError
:
type
=
''
except
KeyError
:
type
=
''
...
@@ -203,6 +209,9 @@ def subclass(c,super):
...
@@ -203,6 +209,9 @@ def subclass(c,super):
##############################################################################
##############################################################################
#
#
# $Log: Folder.py,v $
# $Log: Folder.py,v $
# Revision 1.54 1998/11/26 21:11:35 amos
# Added more doc strings and converted some comments to doc strings.
#
# Revision 1.53 1998/08/26 18:33:44 brian
# Revision 1.53 1998/08/26 18:33:44 brian
# Updated permissions in Folder folder for the copy/paste methods and added
# Updated permissions in Folder folder for the copy/paste methods and added
# cvs log to Folder.py
# cvs log to Folder.py
...
...
lib/python/OFS/Moniker.py
View file @
0f6094d8
...
@@ -6,13 +6,17 @@
...
@@ -6,13 +6,17 @@
and aquisition relationships via a simple interface.
and aquisition relationships via a simple interface.
"""
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
Globals
import
Globals
class
Moniker
:
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 session context
and aquisition relationships via a simple interface."""
def
__init__
(
self
,
ob
=
None
):
def
__init__
(
self
,
ob
=
None
):
if
ob
is
None
:
return
if
ob
is
None
:
return
self
.
jar
=
ob
.
_p_jar
.
name
self
.
jar
=
ob
.
_p_jar
.
name
...
@@ -33,7 +37,7 @@ class Moniker:
...
@@ -33,7 +37,7 @@ class Moniker:
return
absattr
(
self
.
bind
().
meta_type
)
return
absattr
(
self
.
bind
().
meta_type
)
def
bind
(
self
):
def
bind
(
self
):
# Return the real object named by this moniker
"Return the real object named by this moniker"
if
self
.
jar
is
None
:
jar
=
Globals
.
Bobobase
.
_jar
if
self
.
jar
is
None
:
jar
=
Globals
.
Bobobase
.
_jar
else
:
jar
=
Globals
.
SessionBase
[
self
.
jar
].
jar
else
:
jar
=
Globals
.
SessionBase
[
self
.
jar
].
jar
ob
=
None
ob
=
None
...
@@ -45,9 +49,9 @@ class Moniker:
...
@@ -45,9 +49,9 @@ class Moniker:
return
ob
return
ob
def
exact
(
self
,
ob
):
def
exact
(
self
,
ob
):
#
Check against another moniker to see if it
"""
Check against another moniker to see if it
#
refers to the exact same object in the exact
refers to the exact same object in the exact
# same acquisition context.
same acquisition context."""
return
self
.
jar
==
ob
.
jar
and
self
.
ids
==
ob
.
ids
return
self
.
jar
==
ob
.
jar
and
self
.
ids
==
ob
.
ids
...
@@ -62,6 +66,9 @@ def absattr(attr):
...
@@ -62,6 +66,9 @@ def absattr(attr):
##############################################################################
##############################################################################
#
#
# $Log: Moniker.py,v $
# $Log: Moniker.py,v $
# Revision 1.7 1998/11/26 21:11:35 amos
# Added more doc strings and converted some comments to doc strings.
#
# Revision 1.6 1998/11/20 18:16:37 jim
# Revision 1.6 1998/11/20 18:16:37 jim
# First crack at new layout and 1.5 support
# First crack at new layout and 1.5 support
#
#
...
...
lib/python/OFS/SimpleItem.py
View file @
0f6094d8
...
@@ -16,8 +16,8 @@ Aqueduct database adapters, etc.
...
@@ -16,8 +16,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
This module can also be used as a simple template for implementing new
item types.
item types.
$Id: SimpleItem.py,v 1.2
3 1998/11/23 22:57:05 jim
Exp $'''
$Id: SimpleItem.py,v 1.2
4 1998/11/26 21:11:35 amos
Exp $'''
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
import
regex
,
sys
,
Globals
,
App
.
Management
import
regex
,
sys
,
Globals
,
App
.
Management
from
DateTime
import
DateTime
from
DateTime
import
DateTime
...
@@ -28,7 +28,7 @@ from types import InstanceType, StringType
...
@@ -28,7 +28,7 @@ from types import InstanceType, StringType
HTML
=
Globals
.
HTML
HTML
=
Globals
.
HTML
class
Item
(
CopySource
,
App
.
Management
.
Tabs
):
class
Item
(
CopySource
,
App
.
Management
.
Tabs
):
"""A simple Principia object. Not Folderish."""
isPrincipiaFolderish
=
0
isPrincipiaFolderish
=
0
isTopLevelPrincipiaApplicationObject
=
0
isTopLevelPrincipiaApplicationObject
=
0
...
@@ -54,30 +54,36 @@ class Item(CopySource, App.Management.Tabs):
...
@@ -54,30 +54,36 @@ class Item(CopySource, App.Management.Tabs):
},
},
)
)
# Utility that returns the title if it is not blank and the id
# otherwise.
def
title_or_id
(
self
):
def
title_or_id
(
self
):
"""
Utility that returns the title if it is not blank and the id
otherwise.
"""
return
self
.
title
or
self
.
id
return
self
.
title
or
self
.
id
# Utility that returns the title if it is not blank and the id
# otherwise. If the title is not blank, then the id is included
# in parens.
def
title_and_id
(
self
):
def
title_and_id
(
self
):
"""
Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens.
"""
t
=
self
.
title
t
=
self
.
title
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
id
))
or
self
.
id
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
id
))
or
self
.
id
# Handy way to talk to ourselves in document templates.
def
this
(
self
):
def
this
(
self
):
"Handy way to talk to ourselves in document templates."
return
self
return
self
# Interact with tree tag
def
tpURL
(
self
):
def
tpURL
(
self
):
"My URL as used by tree tag"
url
=
self
.
id
url
=
self
.
id
if
hasattr
(
url
,
'im_func'
):
url
=
url
()
if
hasattr
(
url
,
'im_func'
):
url
=
url
()
return
url
return
url
def
tpValues
(
self
):
return
()
def
tpValues
(
self
):
"My sub-objects as used by the tree tag"
return
()
_manage_editedDialog
=
Globals
.
HTMLFile
(
'editedDialog'
,
globals
())
_manage_editedDialog
=
Globals
.
HTMLFile
(
'editedDialog'
,
globals
())
def
manage_editedDialog
(
self
,
REQUEST
,
**
args
):
def
manage_editedDialog
(
self
,
REQUEST
,
**
args
):
...
@@ -137,16 +143,17 @@ class Item(CopySource, App.Management.Tabs):
...
@@ -137,16 +143,17 @@ class Item(CopySource, App.Management.Tabs):
raise
'Redirect'
,
"%s/manage_main"
%
URL1
raise
'Redirect'
,
"%s/manage_main"
%
URL1
class
Item_w__name__
(
Item
):
class
Item_w__name__
(
Item
):
"""Mixin class to support common name/id functions"""
# Utility that returns the title if it is not blank and the id
# otherwise.
def
title_or_id
(
self
):
def
title_or_id
(
self
):
"""Utility that returns the title if it is not blank and the id
otherwise."""
return
self
.
title
or
self
.
__name__
return
self
.
title
or
self
.
__name__
# Utility that returns the title if it is not blank and the id
# otherwise. If the title is not blank, then the id is included
# in parens.
def
title_and_id
(
self
):
def
title_and_id
(
self
):
"""Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens."""
t
=
self
.
title
t
=
self
.
title
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
__name__
))
or
self
.
__name__
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
__name__
))
or
self
.
__name__
...
@@ -191,6 +198,9 @@ def pretty_tb(t,v,tb):
...
@@ -191,6 +198,9 @@ def pretty_tb(t,v,tb):
##############################################################################
##############################################################################
#
#
# $Log: SimpleItem.py,v $
# $Log: SimpleItem.py,v $
# Revision 1.24 1998/11/26 21:11:35 amos
# Added more doc strings and converted some comments to doc strings.
#
# Revision 1.23 1998/11/23 22:57:05 jim
# Revision 1.23 1998/11/23 22:57:05 jim
# First crack at updating error handling to work with 1.5
# First crack at updating error handling to work with 1.5
#
#
...
...
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