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"""
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
from
marshal
import
loads
,
dumps
...
...
@@ -11,7 +11,7 @@ from App.Dialogs import MessageDialog
CopyError
=
'Copy Error'
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
):
"""Put a reference to the objects named in ids in the clip board"""
...
...
@@ -176,12 +176,13 @@ class CopyContainer:
return
ob
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'
])
except
:
return
0
return
1
def
cb_dataItems
(
self
):
"List of objects in the clip board"
try
:
cp
=
_cb_decode
(
self
.
REQUEST
[
'__cp'
])
except
:
return
[]
oblist
=
[]
...
...
@@ -252,17 +253,17 @@ Globals.default__class_init__(CopyContainer)
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
):
#
Called to make sure this object is copyable. The op var
# is 0 for a copy, 1 for a move.
"""
Called to make sure this object is copyable. The op var
is 0 for a copy, 1 for a move."""
return
1
def
_notifyOfCopyTo
(
self
,
container
,
op
=
0
):
#
Overide this to be pickly about where you go! If you dont
#
want to go there, raise an exception. The op variable is
# 0 for a copy, 1 for a move.
"""
Overide this to be pickly about where you go! If you dont
want to go there, raise an exception. The op variable is
0 for a copy, 1 for a move."""
pass
def
_getCopy
(
self
,
container
):
...
...
@@ -284,13 +285,15 @@ class CopySource:
self
.
id
=
id
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
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
return
0
return
1
def
cb_isMoveable
(
self
):
"""Is object moveable? Returns 0 or 1"""
if
not
(
hasattr
(
self
,
'_canCopy'
)
and
self
.
_canCopy
(
1
)):
return
0
if
hasattr
(
self
,
'_p_jar'
)
and
self
.
_p_jar
is
None
:
...
...
@@ -395,6 +398,9 @@ eNotSupported=fMessageDialog(
##############################################################################
#
# $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
# Rearranged order of operations to make move and copy consistent.
# In particular, copy or moved object has new ID *before* it gets
...
...
lib/python/OFS/Document.py
View file @
0f6094d8
"""Document object"""
__version__
=
'$Revision: 1.6
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.6
8
$'
[
11
:
-
2
]
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
...
...
@@ -13,7 +13,8 @@ from DocumentTemplate.DT_Util import cDocument
class
Document
(
cDocument
,
HTML
,
Explicit
,
RoleManager
,
Item_w__name__
,
):
""" """
"""Document object. Basically a DocumentTemplate.HTML object
which operates as a Principia object."""
meta_type
=
'Document'
icon
=
'p_/doc'
_proxy_roles
=
()
...
...
@@ -67,7 +68,8 @@ class Document(cDocument, HTML, Explicit,
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_title'
]
=
self
.
title
if
client
is
None
:
...
...
@@ -179,7 +181,7 @@ class Document(cDocument, HTML, Explicit,
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
.
munge
(
BODY
)
...
...
@@ -215,7 +217,9 @@ class Document(cDocument, HTML, Explicit,
message
=
'Your changes have been saved'
,
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-->
<H2><!--#var title_or_id--> <!--#var document_title--></H2>
...
...
@@ -243,7 +247,7 @@ def manage_addDocument(self, id, title='',file='', REQUEST=None, submit=None):
return
''
class
DocumentHandler
:
"""
"""
"""
Mixin class for objects that can contain Documents.
"""
def
documentIds
(
self
):
t
=
[]
...
...
lib/python/OFS/Folder.py
View file @
0f6094d8
"""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
...
...
@@ -97,6 +99,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
manage_addObject__roles__
=
None
def
tpValues
(
self
):
"""Returns a list of the folder's sub-folders, used by tree tag."""
r
=
[]
if
hasattr
(
self
.
aq_base
,
'tree_ids'
):
for
id
in
self
.
aq_base
.
tree_ids
:
...
...
@@ -134,7 +137,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
# The Following methods are short-term measures to get Paul off my back;)
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
else
:
o
=
getattr
(
self
.
o
)
f
=
Globals
.
data_dir
+
'/export.bbe'
...
...
@@ -142,7 +146,7 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
return
f
def
manage_importHack
(
self
,
REQUEST
=
None
):
"
"
"
Imports a previously exported object from /var/export.bbe
"
f
=
Globals
.
data_dir
+
'/export.bbe'
o
=
self
.
_p_jar
.
import_file
(
f
)
id
=
o
.
id
...
...
@@ -151,14 +155,16 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
return
'OK, I imported %s'
%
id
class
PUTer
:
""" """
"""Class to support the HTTP PUT protocol."""
def
__init__
(
self
,
parent
,
key
):
self
.
_parent
=
parent
self
.
_key
=
key
self
.
__roles__
=
parent
.
PUT__roles__
def
PUT
(
self
,
REQUEST
,
BODY
):
""" """
"""Adds a document, image or file to the folder when a PUT
request is received."""
name
=
self
.
_key
try
:
type
=
REQUEST
[
'CONTENT_TYPE'
]
except
KeyError
:
type
=
''
...
...
@@ -203,6 +209,9 @@ def subclass(c,super):
##############################################################################
#
# $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
# Updated permissions in Folder folder for the copy/paste methods and added
# cvs log to Folder.py
...
...
lib/python/OFS/Moniker.py
View file @
0f6094d8
...
...
@@ -6,13 +6,17 @@
and aquisition relationships via a simple interface.
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
Globals
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
):
if
ob
is
None
:
return
self
.
jar
=
ob
.
_p_jar
.
name
...
...
@@ -33,7 +37,7 @@ class Moniker:
return
absattr
(
self
.
bind
().
meta_type
)
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
else
:
jar
=
Globals
.
SessionBase
[
self
.
jar
].
jar
ob
=
None
...
...
@@ -45,9 +49,9 @@ class Moniker:
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.
"""
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
...
...
@@ -62,6 +66,9 @@ def absattr(attr):
##############################################################################
#
# $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
# 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.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.2
3 1998/11/23 22:57:05 jim
Exp $'''
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
$Id: SimpleItem.py,v 1.2
4 1998/11/26 21:11:35 amos
Exp $'''
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
import
regex
,
sys
,
Globals
,
App
.
Management
from
DateTime
import
DateTime
...
...
@@ -28,7 +28,7 @@ from types import InstanceType, StringType
HTML
=
Globals
.
HTML
class
Item
(
CopySource
,
App
.
Management
.
Tabs
):
"""A simple Principia object. Not Folderish."""
isPrincipiaFolderish
=
0
isTopLevelPrincipiaApplicationObject
=
0
...
...
@@ -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
):
"""
Utility that returns the title if it is not blank and the id
otherwise.
"""
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
):
"""
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
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
id
))
or
self
.
id
# Handy way to talk to ourselves in document templates.
def
this
(
self
):
"Handy way to talk to ourselves in document templates."
return
self
# Interact with tree tag
def
tpURL
(
self
):
"My URL as used by tree tag"
url
=
self
.
id
if
hasattr
(
url
,
'im_func'
):
url
=
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
())
def
manage_editedDialog
(
self
,
REQUEST
,
**
args
):
...
...
@@ -137,16 +143,17 @@ class Item(CopySource, App.Management.Tabs):
raise
'Redirect'
,
"%s/manage_main"
%
URL1
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
):
"""Utility that returns the title if it is not blank and the id
otherwise."""
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
):
"""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
return
t
and
(
"%s (%s)"
%
(
t
,
self
.
__name__
))
or
self
.
__name__
...
...
@@ -191,6 +198,9 @@ def pretty_tb(t,v,tb):
##############################################################################
#
# $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
# 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