Commit 744b9489 authored by Evan Simpson's avatar Evan Simpson

Made 'record' class act like a mapping, primarily so that you can pass it to a...

Made 'record' class act like a mapping, primarily so that you can pass it to a propertysheet's change or edit methods.  It is also nice to be able to inspect a record's keys().
parent 59782e7f
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.29 $'[11:-2] __version__='$Revision: 1.30 $'[11:-2]
import regex, sys, os, string import regex, sys, os, string
from string import lower, atoi, rfind, split, strip, join, upper, find from string import lower, atoi, rfind, split, strip, join, upper, find
...@@ -976,8 +976,21 @@ def parse_cookie(text, ...@@ -976,8 +976,21 @@ def parse_cookie(text,
return apply(parse_cookie,(text[l:],result)) return apply(parse_cookie,(text[l:],result))
import sys
# add class # add class
class record: class record:
def __getattr__(self, key, default=None):
if key in ('get', 'keys', 'items', 'values', 'copy', 'has_key'):
return getattr(self.__dict__, key)
try:
return self.__dict__[key]
except KeyError, kerr:
raise AttributeError, kerr, sys.exc_info()[2]
def __getitem__(self, key):
return self.__dict__[key]
def __str__(self): def __str__(self):
L1 = self.__dict__.items() L1 = self.__dict__.items()
L1.sort() L1.sort()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment