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
7578b7ac
Commit
7578b7ac
authored
Oct 29, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added careful_getslice.
parent
e39808e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+24
-2
No files found.
lib/python/DocumentTemplate/DT_Util.py
View file @
7578b7ac
'''$Id: DT_Util.py,v 1.
7 1997/10/28 22:10:46
jim Exp $'''
'''$Id: DT_Util.py,v 1.
8 1997/10/29 16:17:45
jim Exp $'''
############################################################################
############################################################################
# Copyright
# Copyright
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
# (540) 371-6909
# (540) 371-6909
#
#
############################################################################
############################################################################
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
import
sys
,
regex
,
string
,
types
,
math
,
os
import
sys
,
regex
,
string
,
types
,
math
,
os
from
string
import
rfind
,
strip
,
joinfields
,
atoi
,
lower
,
upper
,
capitalize
from
string
import
rfind
,
strip
,
joinfields
,
atoi
,
lower
,
upper
,
capitalize
...
@@ -101,6 +101,24 @@ def careful_getitem(mapping, key, md):
...
@@ -101,6 +101,24 @@ def careful_getitem(mapping, key, md):
if
validate
is
None
or
validate
(
mapping
,
mapping
,
key
,
v
,
md
):
return
v
if
validate
is
None
or
validate
(
mapping
,
mapping
,
key
,
v
,
md
):
return
v
raise
KeyError
,
key
raise
KeyError
,
key
def
careful_getslice
(
seq
,
indexes
,
md
):
v
=
len
(
indexes
)
if
v
==
2
:
v
=
seq
[
indexes
[
0
]:
indexes
[
1
]]
elif
v
==
1
:
v
=
seq
[
indexes
[
0
]:]
else
:
v
=
seq
[:]
if
type
(
seq
)
is
type
(
''
):
return
v
# Short-circuit common case
validate
=
md
.
validate
if
validate
is
not
None
:
for
e
in
v
:
if
not
validate
(
seq
,
seq
,
''
,
e
,
md
):
raise
TypeError
,
'unauthorized access to slice member'
return
v
def
name_param
(
params
,
tag
=
''
,
expr
=
0
):
def
name_param
(
params
,
tag
=
''
,
expr
=
0
):
used
=
params
.
has_key
used
=
params
.
has_key
if
used
(
''
):
if
used
(
''
):
...
@@ -121,6 +139,7 @@ def name_param(params,tag='',expr=0):
...
@@ -121,6 +139,7 @@ def name_param(params,tag='',expr=0):
__mul__
=
VSEval
.
careful_mul
,
__mul__
=
VSEval
.
careful_mul
,
__getattr__
=
careful_getattr
,
__getattr__
=
careful_getattr
,
__getitem__
=
careful_getitem
,
__getitem__
=
careful_getitem
,
__getslice__
=
careful_getslice
,
)
)
return
name
,
expr
return
name
,
expr
...
@@ -197,6 +216,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
...
@@ -197,6 +216,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
############################################################################
############################################################################
# $Log: DT_Util.py,v $
# $Log: DT_Util.py,v $
# Revision 1.8 1997/10/29 16:17:45 jim
# Added careful_getslice.
#
# Revision 1.7 1997/10/28 22:10:46 jim
# Revision 1.7 1997/10/28 22:10:46 jim
# changed '
acquire
' to '
aq_acquire
'.
# changed '
acquire
' to '
aq_acquire
'.
#
#
...
...
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