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
c5c8d165
Commit
c5c8d165
authored
Oct 22, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a default argument to _.getattr.
parent
b5722153
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+11
-6
No files found.
lib/python/DocumentTemplate/DT_Util.py
View file @
c5c8d165
...
...
@@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
'''$Id: DT_Util.py,v 1.6
0 1999/10/20 21:56:43 kl
m Exp $'''
__version__
=
'$Revision: 1.6
0
$'
[
11
:
-
2
]
'''$Id: DT_Util.py,v 1.6
1 1999/10/22 18:08:45 ji
m Exp $'''
__version__
=
'$Revision: 1.6
1
$'
[
11
:
-
2
]
import
regex
,
string
,
math
,
os
from
string
import
strip
,
join
,
atoi
,
lower
,
split
,
find
...
...
@@ -116,13 +116,19 @@ def int_param(params,md,name,default=0, st=type('')):
if
type
(
v
)
is
st
:
v
=
atoi
(
v
)
return
v
or
0
def
careful_getattr
(
md
,
inst
,
name
):
_marker
=
[]
def
careful_getattr
(
md
,
inst
,
name
,
default
=
_marker
):
if
name
[:
1
]
!=
'_'
:
# Try to get the attribute normally so that we don't
# accidentally acquire when we shouldn't.
v
=
getattr
(
inst
,
name
)
try
:
v
=
getattr
(
inst
,
name
)
except
:
if
default
is
not
_marker
:
return
default
raise
validate
=
md
.
validate
...
...
@@ -135,7 +141,6 @@ def careful_getattr(md, inst, name):
raise
ValidationError
,
name
_marker
=
[]
def
careful_hasattr
(
md
,
inst
,
name
):
v
=
getattr
(
inst
,
name
,
_marker
)
if
v
is
not
_marker
:
...
...
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