[Zope-dev] patch zope-2.4.0 and guarded_getattr (and PageTemplates): is this a bug?

Joseph Wayne Norton norton@arseed.co.jp
Wed, 18 Jul 2001 16:17:42 +0900


Hello.

I'm currently testing the following components together:

  - python 2.1.0
  - zope 2.4.0 (CVS version)
  - PageTemplates and TAL 1.3.2 (CVS version)
  - CMF 1.1 (CVS version)

I'm having trouble using the ZPT skins included with CMFDecor and my
own customs skins. The following patch (below) fixes the troubles I'm
facing.

Is this patch correct or not?

regards,

- joe n.


Index: lib/python/DocumentTemplate/DT_Util.py
===================================================================
RCS file: /cvs-repository/Packages/DocumentTemplate/DT_Util.py,v
retrieving revision 1.82
diff -r1.82 DT_Util.py
148c148
<     get = md.guarded_getattr
---
>     get = getattr(md, 'guarded_getattr', None)
159c159
<     get = md.guarded_getattr
---
>     get = getattr(md, 'guarded_getattr', None)
Index: lib/python/DocumentTemplate/cDocumentTemplate.c
===================================================================
RCS file: /cvs-repository/Packages/DocumentTemplate/cDocumentTemplate.c,v
retrieving revision 1.39
diff -r1.39 cDocumentTemplate.c
130,134c130,139
<   else
<     UNLESS(self->guarded_getattr=PyObject_GetAttr(self->namespace,
<                                                   py_guarded_getattr))
<        return NULL;
<     
---
>   else if (PyObject_HasAttr(self->namespace,py_guarded_getattr)) 
>   {
>       UNLESS(self->guarded_getattr=PyObject_GetAttr(self->namespace,
>                                                     py_guarded_getattr))
>           return NULL;
>   } else 
>   {
>       self->guarded_getattr = Py_None;
>   }
>   
Index: lib/python/DocumentTemplate/pDocumentTemplate.py
===================================================================
RCS file: /cvs-repository/Packages/DocumentTemplate/pDocumentTemplate.py,v
retrieving revision 1.31
diff -r1.31 pDocumentTemplate.py
129c129
<             self.guarded_getattr = namespace.guarded_getattr
---
>             self.guarded_getattr = getattr(namespace, 'guarded_getattr', None)