Merge pull request #11 from plone/attribute-lookup-optimization

Return early for attributes that begin with two underscores
This commit is contained in:
Rok Garbas 2012-12-05 20:29:01 -08:00
commit ceeb72b61a
1 changed files with 7 additions and 2 deletions

View File

@ -177,10 +177,15 @@ class DexterityContent(DAVResourceMixin, PortalContent, DefaultDublinCoreImpl, C
description = u''
def __getattr__(self, name):
# optimization: sometimes we're asked for special attributes
# such as __conform__ that we can disregard (because we
# wouldn't be in here if the class had such an attribute
# defined).
if name.startswith('__'):
raise AttributeError(name)
# attribute was not found; try to look it up in the schema and return
# a default
schema = SCHEMA_CACHE.get(self.portal_type)
if schema is not None:
field = schema.get(name, None)