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
8f3e9667
Commit
8f3e9667
authored
Apr 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make simpler-to-use Tree
parent
9108b1a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
15 deletions
+147
-15
lib/python/ZTUtils/Batch.py
lib/python/ZTUtils/Batch.py
+11
-11
lib/python/ZTUtils/SimpleTree.py
lib/python/ZTUtils/SimpleTree.py
+129
-0
lib/python/ZTUtils/Tree.py
lib/python/ZTUtils/Tree.py
+4
-2
lib/python/ZTUtils/__init__.py
lib/python/ZTUtils/__init__.py
+3
-2
No files found.
lib/python/ZTUtils/Batch.py
View file @
8f3e9667
...
...
@@ -84,15 +84,15 @@
##############################################################################
__doc__
=
'''Batch class, for iterating over a sequence in batches
$Id: Batch.py,v 1.
1 2001/04/27 16:38:52
evan Exp $'''
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
$Id: Batch.py,v 1.
2 2001/04/27 20:51:20
evan Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
from
ExtensionClass
import
Base
class
LazyPrevBatch
(
Base
):
def
__of__
(
self
,
parent
):
return
Batch
(
parent
.
_sequence
,
parent
.
_size
,
0
,
parent
.
_
first
+
parent
.
overlap
,
-
1
,
parent
.
first
+
parent
.
overlap
,
parent
.
orphan
,
parent
.
overlap
)
class
LazyNextBatch
(
Base
):
...
...
@@ -107,8 +107,8 @@ class Batch(Base):
"""Create a sequence batch"""
__allow_access_to_unprotected_subobjects__
=
1
previous
=
LazyPrevBatch
(
0
)
next
=
LazyNextBatch
(
1
)
previous
=
LazyPrevBatch
()
next
=
LazyNextBatch
()
def
__init__
(
self
,
sequence
,
size
,
start
=
0
,
end
=
0
,
orphan
=
3
,
overlap
=
0
):
...
...
@@ -124,19 +124,19 @@ class Batch(Base):
self
.
end
=
end
self
.
orphan
=
orphan
self
.
overlap
=
overlap
self
.
_
first
=
max
(
start
-
1
,
0
)
self
.
length
=
self
.
end
-
self
.
_
first
if
self
.
_
first
==
0
:
self
.
first
=
max
(
start
-
1
,
0
)
self
.
length
=
self
.
end
-
self
.
first
if
self
.
first
==
0
:
self
.
previous
=
None
def
__getitem__
(
self
,
index
):
if
index
<
0
:
if
index
+
self
.
end
<
self
.
_
first
:
raise
IndexError
,
index
if
index
+
self
.
end
<
self
.
first
:
raise
IndexError
,
index
return
self
.
_sequence
[
index
+
self
.
end
]
if
index
>=
self
.
end
:
raise
IndexError
,
index
return
self
.
_sequence
[
index
+
self
.
_
first
]
if
index
>=
self
.
size
:
raise
IndexError
,
index
return
self
.
_sequence
[
index
+
self
.
first
]
def
__len__
(
self
):
return
self
.
length
...
...
lib/python/ZTUtils/SimpleTree.py
0 → 100644
View file @
8f3e9667
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__
=
'''Simple Tree classes
$Id: SimpleTree.py,v 1.1 2001/04/27 20:51:20 evan Exp $'''
__version__
=
'$Revision: 1.1 $'
[
11
:
-
2
]
from
Tree
import
TreeMaker
,
TreeNode
,
b2a
class
SimpleTreeNode
(
TreeNode
):
def
branch
(
self
):
if
self
.
state
==
0
:
return
{
'link'
:
None
,
'img'
:
' '
}
if
self
.
state
<
0
:
setst
=
'expand'
exnum
=
self
.
aq_parent
.
expansion_number
img
=
'pl'
else
:
setst
=
'collapse'
exnum
=
self
.
expansion_number
img
=
'mi'
base
=
self
.
aq_acquire
(
'baseURL'
)
obid
=
self
.
id
pre
=
self
.
aq_acquire
(
'tree_pre'
)
return
{
'link'
:
'?%s-setstate=%s,%s,%s#%s'
%
(
pre
,
setst
[
0
],
exnum
,
obid
,
obid
),
'img'
:
'<img src="%s/p_/%s" alt="%s" border="0">'
%
(
base
,
img
,
setst
)}
class
SimpleTreeMaker
(
TreeMaker
):
'''Generate Simple Trees'''
def
__init__
(
self
,
tree_pre
=
"tree"
):
self
.
tree_pre
=
tree_pre
def
node
(
self
,
object
):
node
=
SimpleTreeNode
()
node
.
object
=
object
node
.
id
=
b2a
(
self
.
getId
(
object
))
return
node
def
markRoot
(
self
,
node
):
node
.
tree_pre
=
self
.
tree_pre
node
.
baseURL
=
node
.
object
.
REQUEST
[
'BASEPATH1'
]
lib/python/ZTUtils/Tree.py
View file @
8f3e9667
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
'''Tree manipulation classes
$Id: Tree.py,v 1.
1 2001/04/27 16:38:52
evan Exp $'''
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
$Id: Tree.py,v 1.
2 2001/04/27 20:51:20
evan Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
from
Acquisition
import
Explicit
from
ComputedAttribute
import
ComputedAttribute
...
...
@@ -158,6 +158,8 @@ class TreeMaker:
node
.
state
=
-
1
# collapsed
if
not
subtree
:
node
.
depth
=
0
if
hasattr
(
self
,
'markRoot'
):
self
.
markRoot
(
node
)
return
node
def
node
(
self
,
object
):
...
...
lib/python/ZTUtils/__init__.py
View file @
8f3e9667
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
'''Package of template utility classes and functions.
$Id: __init__.py,v 1.
1 2001/04/27 16:38:52
evan Exp $'''
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
$Id: __init__.py,v 1.
2 2001/04/27 20:51:20
evan Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__allow_access_to_unprotected_subobjects__
=
1
__roles__
=
None
...
...
@@ -93,3 +93,4 @@ __roles__ = None
from
Batch
import
Batch
from
Iterator
import
Iterator
from
Tree
import
TreeMaker
,
encodeExpansion
,
decodeExpansion
,
a2b
,
b2a
from
SimpleTree
import
SimpleTreeMaker
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