Mark Hildreth wrote:
> hasattr returns true because of the way that tmpl_context ("c") is
> implemented.
>
> https://www.knowledgetap.com/hg/pylons-dev/file/98d7b9278acd/pylons/util.py#l115
>
> You have ContextObj, and AttribSafeContextObj. By default, Pylons uses
> AttribSafeContextObj. Looking at the code, you can see that the
> __getattr__ method is overridden. This returns an empty string. For
> more infoon __getattr__, see here:
>
> http://docs.python.org/reference/datamodel.html#object.__getattr__
>
> Now, hasattr returns true because, no matter what name you put, if it
> is not found on the actual context, it will still be "found" since we
> are by default returning an empty string.
>
> When you use strict_c, you are using the ContextObj, which does not
> override __getattr__, and as such has the default behavior of raising
> an exception as well as returning false from hasattr when the
> attribute is not found.
That was educational, thanks..
Regards,
mk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---