Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
1ef4f906
Commit
1ef4f906
authored
May 02, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced the context module's use of _is_callable() with Python's built-in callable().
parent
d570f70a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
pystache/context.py
+3
-6
No files found.
pystache/context.py
View file @
1ef4f906
...
...
@@ -22,11 +22,6 @@ class NotFound(object):
_NOT_FOUND
=
NotFound
()
# TODO: share code with template.check_callable().
def
_is_callable
(
obj
):
return
hasattr
(
obj
,
'__call__'
)
# TODO: document what a "context" is as opposed to a context stack.
def
_get_value
(
context
,
key
):
"""
...
...
@@ -54,7 +49,9 @@ def _get_value(context, key):
# are considered objects by the test above.
if
hasattr
(
context
,
key
):
attr
=
getattr
(
context
,
key
)
if
_is_callable
(
attr
):
# TODO: consider using EAFP here instead.
# http://docs.python.org/glossary.html#term-eafp
if
callable
(
attr
):
return
attr
()
return
attr
...
...
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