[Checkins] SVN: z3c.pt/trunk/ Avoid a try/except in
Lookup.lookup_attr and use a getattr with an `is marker`
comparison instead.
Hanno Schlichting
plone at hannosch.info
Fri Jul 18 05:02:53 EDT 2008
Log message for revision 88477:
Avoid a try/except in Lookup.lookup_attr and use a getattr with an `is marker` comparison instead.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/codegen.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-07-18 08:54:34 UTC (rev 88476)
+++ z3c.pt/trunk/CHANGES.txt 2008-07-18 09:02:51 UTC (rev 88477)
@@ -4,6 +4,9 @@
Version 0.8.x
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- Avoid a try/except in Lookup.lookup_attr and use a getattr with an
+ `is marker` comparison instead.
+
- Simplified the _escape function handling by pulling in the str call into the
function. Corrected the bigtable hotshot test to only benchmark rendering.
Modified: z3c.pt/trunk/src/z3c/pt/codegen.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/codegen.py 2008-07-18 08:54:34 UTC (rev 88476)
+++ z3c.pt/trunk/src/z3c/pt/codegen.py 2008-07-18 09:02:51 UTC (rev 88477)
@@ -24,13 +24,13 @@
@classmethod
def lookup_attr(cls, obj, key):
- try:
- return getattr(obj, key)
- except AttributeError, e:
+ value = getattr(obj, key, marker)
+ if value is marker:
try:
return obj[key]
except (KeyError, TypeError):
raise e
+ return value
class TemplateASTTransformer(ASTTransformer):
def __init__(self):
More information about the Checkins
mailing list