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
dc1f5073
Commit
dc1f5073
authored
Sep 17, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved algorithm for calling objects.
parent
eeca8a44
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
lib/python/DocumentTemplate/pDocumentTemplate.py
lib/python/DocumentTemplate/pDocumentTemplate.py
+17
-18
No files found.
lib/python/DocumentTemplate/pDocumentTemplate.py
View file @
dc1f5073
...
...
@@ -54,8 +54,8 @@
__doc__
=
'''Python implementations of document template some features
$Id: pDocumentTemplate.py,v 1.
19 1998/09/16 20:19:12
jim Exp $'''
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
$Id: pDocumentTemplate.py,v 1.
20 1998/09/17 10:12:20
jim Exp $'''
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
import
string
,
sys
,
types
from
string
import
join
...
...
@@ -64,7 +64,7 @@ StringType=type('')
TupleType
=
type
(())
isFunctionType
=
{}
for
name
in
[
'BuiltinFunctionType'
,
'BuiltinMethodType'
,
'ClassType'
,
'FunctionType'
,
'LambdaType'
,
'MethodType'
]:
'FunctionType'
,
'LambdaType'
,
'MethodType'
,
'UnboundMethodType'
]:
try
:
isFunctionType
[
getattr
(
types
,
name
)]
=
1
except
:
pass
...
...
@@ -76,6 +76,14 @@ except: pass
isFunctionType
=
isFunctionType
.
has_key
isSimpleType
=
{}
for
n
in
dir
(
types
):
if
(
n
[
-
4
:]
==
'Type'
and
n
!=
'InstanceType'
and
not
isFunctionType
(
getattr
(
types
,
n
))):
isSimpleType
[
getattr
(
types
,
n
)]
=
1
isSimpleType
=
isSimpleType
.
has_key
class
InstanceDict
:
validate
=
None
...
...
@@ -151,33 +159,24 @@ class TemplateDict:
except
:
pass
def
__getitem__
(
self
,
key
,
call
=
1
,
simple
=
{
type
(
''
):
1
,
type
(
0
):
1
,
type
(
0.0
):
1
,
type
([]):
1
,
type
(()):
1
,
}.
has_key
):
simple
=
isSimpleType
,
isFunctionType
=
isFunctionType
,
):
v
=
self
.
dicts
[
key
]
if
call
and
not
simple
(
type
(
v
)):
if
hasattr
(
v
,
'isDocTemp'
)
and
v
.
isDocTemp
:
v
=
v
(
None
,
self
)
if
hasattr
(
v
,
'isDocTemp'
)
and
v
.
isDocTemp
:
return
v
(
None
,
self
)
elif
isFunctionType
(
type
(
v
)):
return
v
(
)
else
:
try
:
return
v
()
except
AttributeError
,
ev
:
try
:
tb
=
sys
.
exc_traceback
if
hasattr
(
sys
,
'exc_info'
):
tb
=
sys
.
exc_info
()[
2
]
if
isFunctionType
(
type
(
v
)):
raise
AttributeError
,
ev
,
tb
if
hasattr
(
v
,
'__call__'
):
raise
AttributeError
,
ev
,
tb
finally
:
tb
=
None
except
TypeError
,
ev
:
try
:
tb
=
sys
.
exc_traceback
if
hasattr
(
sys
,
'exc_info'
):
tb
=
sys
.
exc_info
()[
2
]
if
isFunctionType
(
type
(
v
)):
raise
AttributeError
,
ev
,
tb
finally
:
tb
=
None
except
TypeError
:
pass
return
v
...
...
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