[Zope-CMF] Re: [dev] Actions: lazy dict not working with DTML?

Dieter Maurer dieter at handshake.de
Wed Aug 4 18:05:28 EDT 2004


yuppie wrote at 2004-8-4 11:21 +0200:
> ...
>Basically this is a dict with a customized __getitem__ method.
> ...
>class LazyDict(dict):
>    def __getitem__(self, key):
>        return 'bar'

The code in "cDocumentTemplate.c:MM_cget" checks whether
the object is a "dict" and in this case calls
"PyDict_GetItem". This function ignores your "__getitem__" customization
(and directy uses the dict's "__getitem__").

You can replace "dict" above by
"UserDict" (from module "UserDict") and the problem disappears
(as then the "PyDict_Check" will return "false").

-- 
Dieter


More information about the Zope-CMF mailing list