Pylons had the concept of an attribute-safe object ( see below )

I toss it in /lib/helpers and use them throughout my code.  I
typically have my core handler stash an instance or two in the request
object.  All my template variables look to read off this object.



=======

class AttributeSafeObject(object):
    """object, with lax attribute access ( returns '' when the
attribute does not exist). Based on pylons."""

    def __init__(self,**kwargs):
        for key in kwargs:
            setattr(self,key,kwargs[key])

    def __getattr__(self, name):
        try:
            return object.__getattribute__(self,name)
        except AttributeError:
            if 0:
                log.debug("No attribute called %s found on
AttributeSafeObject object, returning empty string", name)
            return ''

-- 
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.

Reply via email to