[Zope-Checkins] CVS: Zope/lib/python/Products/PythonScripts - standard.py:1.10.4.8
Chris McDonough
chrism@zope.com
Fri, 3 Jan 2003 01:33:43 -0500
Update of /cvs-repository/Zope/lib/python/Products/PythonScripts
In directory cvs.zope.org:/tmp/cvs-serv27194/PythonScripts
Modified Files:
Tag: chrism-install-branch
standard.py
Log Message:
Merging chrism-install-branch with HEAD (hopefully for one of the last
times).
=== Zope/lib/python/Products/PythonScripts/standard.py 1.10.4.7 => 1.10.4.8 ===
--- Zope/lib/python/Products/PythonScripts/standard.py:1.10.4.7 Sun Nov 24 19:14:56 2002
+++ Zope/lib/python/Products/PythonScripts/standard.py Fri Jan 3 01:33:10 2003
@@ -61,10 +61,30 @@
class _Object(record):
_guarded_writes = 1
+ def __init__(self, **kw):
+ self.update(kw)
+
def __setitem__(self, key, value):
- self.__dict__[str(key)] = value
+ key = str(key)
+ if key.startswith('_'):
+ raise ValueError, ('Object key %s is invalid. '
+ 'Keys may not begin with an underscore.' % `key`)
+ self.__dict__[key] = value
+
+ def update(self, d):
+ for key in d.keys():
+ # Ignore invalid keys, rather than raising an exception.
+ try:
+ skey = str(key)
+ except:
+ continue
+ if skey==key and not skey.startswith('_'):
+ self.__dict__[skey] = d[key]
+
+ def __hash__(self):
+ return id(self)
-def Object():
- return _Object()
+def Object(**kw):
+ return _Object(**kw)
security.apply(globals())