Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Papa Tamsir Kane
erp5
Commits
3da34864
Commit
3da34864
authored
Jun 22, 2015
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow restricted python to use HBTreeFolder2 iterators.
Partial commit of
c29f5cda
.
parent
b35e8344
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
product/HBTreeFolder2/HBTreeFolder2.py
product/HBTreeFolder2/HBTreeFolder2.py
+73
-0
No files found.
product/HBTreeFolder2/HBTreeFolder2.py
View file @
3da34864
...
...
@@ -32,7 +32,11 @@ from AccessControl import getSecurityManager, ClassSecurityInfo
from
AccessControl.Permissions
import
access_contents_information
,
\
view_management_screens
from
zLOG
import
LOG
,
INFO
,
ERROR
,
WARNING
<<<<<<<
HEAD
from
Products.ZCatalog.Lazy
import
LazyMap
,
LazyFilter
,
LazyCat
,
LazyValues
=======
from
AccessControl.SimpleObjectPolicies
import
ContainerAssertions
>>>>>>>
c29f5cd
...
Allow
restricted
python
to
use
HBTreeFolder2
iterators
.
manage_addHBTreeFolder2Form
=
DTMLFile
(
'folderAdd'
,
globals
())
...
...
@@ -67,6 +71,75 @@ class ExhaustedUniqueIdsError (Exception):
pass
<<<<<<<
HEAD
=======
class
HBTreeObjectIds
(
object
):
_index
=
float
(
'inf'
)
def
__init__
(
self
,
tree
,
base_id
=
_marker
):
self
.
_tree
=
tree
if
base_id
is
_marker
:
tree_id_list
=
tree
.
getTreeIdList
()
self
.
_count
=
tree
.
_count
else
:
tree_id_list
=
base_id
,
check
=
tree
.
_checkObjectId
self
.
_keys
=
lambda
:
(
x
for
base_id
in
tree_id_list
for
x
in
(
tree
.
_htree
if
base_id
is
None
else
tree
.
_getTree
(
base_id
)).
keys
()
if
check
((
base_id
,
x
)))
def
_count
(
self
):
count
=
sum
(
1
for
x
in
self
.
_keys
())
self
.
_count
=
lambda
:
count
return
count
def
__len__
(
self
):
return
self
.
_count
()
def
__iter__
(
self
):
return
self
.
_keys
()
def
__getitem__
(
self
,
item
):
if
item
<
0
:
item
+=
self
.
_count
()
i
=
self
.
_index
self
.
_index
=
item
+
1
i
=
item
-
i
try
:
if
i
<
0
:
self
.
_ikeys
=
keys
=
self
.
_keys
()
return
islice
(
keys
,
item
,
None
).
next
()
return
(
islice
(
self
.
_ikeys
,
i
,
None
)
if
i
else
self
.
_ikeys
).
next
()
except
StopIteration
:
del
self
.
_index
,
self
.
_ikeys
raise
IndexError
ContainerAssertions
[
HBTreeObjectIds
]
=
1
class
HBTreeObjectItems
(
HBTreeObjectIds
):
def
__iter__
(
self
):
getOb
=
self
.
_tree
.
_getOb
return
((
x
,
getOb
(
x
))
for
x
in
self
.
_keys
())
def
__getitem__
(
self
,
item
):
object_id
=
HBTreeObjectIds
.
__getitem__
(
self
,
item
)
return
object_id
,
self
.
_tree
.
_getOb
(
object_id
)
ContainerAssertions
[
HBTreeObjectItems
]
=
1
class
HBTreeObjectValues
(
HBTreeObjectIds
):
def
__iter__
(
self
):
getOb
=
self
.
_tree
.
_getOb
return
(
getOb
(
x
)
for
x
in
self
.
_keys
())
def
__getitem__
(
self
,
item
):
return
self
.
_tree
.
_getOb
(
HBTreeObjectIds
.
__getitem__
(
self
,
item
))
ContainerAssertions
[
HBTreeObjectValues
]
=
1
>>>>>>>
c29f5cd
...
Allow
restricted
python
to
use
HBTreeFolder2
iterators
.
class
HBTreeFolder2Base
(
Persistent
):
"""Base for BTree-based folders.
"""
...
...
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