[Zope] Could namespaces have a .get method?
   
    Chris Withers
     
    chrisw@nipltd.com
       
    Wed, 6 Jun 2001 11:26:41 +0100
    
    
  
> I'm getting a KeyError trying to render non-existant _[variables]
>
> <dtml-var "_[variable]" null="triedthis" missing="triedthistoo">
Why not just do:
<dtml-var variable null="triedthis" missing="triedthistoo">
?
To be honest, though, I've bumped into this a lot and I do wish namespaces
had a get method like dictionaries:
_.get(name,default)
..so you can get around this sort of thing.
Hehe... here's the implementation:
_marker=[]
def get(self,name,default=_marker):
  try:
    return self.__getitem__(name)
  except KeyError:
    if default is not _marker:
      return default
    raise
...could someone add it in or should I stick it in the collector?
cheers,
Chris