[Zope] guarded_getattr attribute error with complex Python structures

Pierre-Julien Grizel grizel@mouli.net
Fri, 03 Aug 2001 18:24:51 +0200


Hi,


I've got a complex Zope problem...

I have a resonably deep imbrication of Python scripts & DTML Methods. It
happends that I finally do something like this :

MyScript:
  return MyMethod(LIST, RECORD_SET)

MyMethod:
  <dtml-in LIST>
    xxx
  </dtml-in>


As you can guess, LIST is a... list (actually a list of tuples built from
another Py script).
When I try the URL, I eventually got the following traceback :


Traceback (most recent call last):
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_Try.py", line 221, in
render_try_except
    result = render_blocks(self.section, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_Util.py", line 230, in
eval
    return eval(code, d)
  File "", line 2, in f
  File "/isp/zope/smartway/lib/python/AccessControl/DTML.py", line 104, in
guarded_getitem
    return guarded_getitem(ob, index)
  File "/isp/zope/smartway/lib/python/AccessControl/ZopeGuards.py", line 151, in
guarded_getitem
    v = object[index]
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_With.py", line 148, in
render
    try: return render_blocks(self.section, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_Return.py", line 104,
in render
    val = md[name]
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_With.py", line 148, in
render
    try: return render_blocks(self.section, md)
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_In.py", line 770, in
renderwob
    try: append(render(section, md))
  File "/isp/zope/smartway/lib/python/OFS/DTMLDocument.py", line 192, in
__call__
    r=apply(HTML.__call__, (self, bself, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_Let.py", line 148, in
render
    return render_blocks(self.section, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_Util.py", line 230, in
eval
    return eval(code, d)
  File "", line 2, in f
  File "/isp/zope/smartway/lib/python/Shared/DC/Scripts/Bindings.py", line 324,
in __call__
    return self._bindAndExec(args, kw, None)
  File "/isp/zope/smartway/lib/python/Shared/DC/Scripts/Bindings.py", line 354,
in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/isp/zope/smartway/lib/python/Products/PythonScripts/PythonScript.py",
line 363, in _exec
    result = apply(f, args, kw)
  File "Script (Python)", line 1, in html_results_list
  File "/isp/zope/smartway/lib/python/OFS/DTMLMethod.py", line 187, in __call__
    r=apply(HTML.__call__, (self, client, REQUEST), kw)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_String.py", line 544,
in __call__
    try: result = render_blocks(self._v_blocks, md)
  File "/isp/zope/smartway/lib/python/DocumentTemplate/DT_In.py", line 768, in
renderwob
    push(InstanceDict(client, md))
AttributeError: guarded_getattr



This happens in fact quite every time I'm handling complex Python data
structures and passing them through scripts and/or methods... Is it a bug or are
my wished to complex ?...



Many thanks,


P.-J.


-- 
If the only tool you have is a hammer, 
    you tend to see every problem as a nail.
Si le seul outil dont vous disposez est un marteau, 
    vous avez tendance à voir chaque problème comme un clou. 
                                       --Abraham Maslow