AttributeError in python script
##parameters=myFolder, myObjectType results=[] for object in container.myFolder.objectValues(myObjectType): tuple = object.title, object.id results.append(tuple) return results I get an attribute error calling the following. tuple_of_items('idofTargetFolder','DTML_Method') I have tried getitem and render. Please help me with what I have missed? Thanks, Trevor
Trevor Toenjes writes: Apparently, you must be more careful, when you describe problems. I already replied to an almost identical problem report, just with a small but essential difference...
##parameters=myFolder, myObjectType results=[] for object in container.myFolder.objectValues(myObjectType): getattr(container,myFolder)
This is called "Computed Attribute Access". You (and others) use it whenever an attribute it either not constant or not a (Python) name... More info in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
Trevor Toenjes writes: Apparently, you must be more careful, when you describe problems. Agreed that I threw off the real issue with a sloppy mistake when copying my example over to email.
I already replied to an almost identical problem report, just with a small but essential difference...
##parameters=myFolder, myObjectType results=[] for object in container.myFolder.objectValues(myObjectType): getattr(container,myFolder)
This is called "Computed Attribute Access". You (and others) use it whenever an attribute it either not constant or not a (Python) name...
The following line tests properly in the script. for object in context[myFolder].objectValues(myObjectType) <<tests correctly It looks like this is an alternative to your suggestion. The continuing issue is...now I am trying to call this tuple for a Formulator Items property override. I include the following for Items and get an AttributeError tuple_of_items(emailscripts,'DTML Method') My assumption is - emailscripts is an object - and DTML Method is a string when processed in the script. But I must still be calling it incorrectly. Maybe Formulator can't populate Items with objects, so I need to convert the id to strings? But I thought the advantage of Formulator was to use objects for use in HTML forms. Thanks for the help. Trevor
Trevor Toenjes writes:
Dieter Maurer writes: ... getattr(context,myFolder).objectValues(...) .... The following line tests properly in the script. for object in context[myFolder].objectValues(myObjectType) <<tests correctly It looks like this is an alternative to your suggestion. It is when "context" is a folder... The difference, subscription does not use acquisition in this case, while "getattr" does.
The continuing issue is...now I am trying to call this tuple for a Formulator Items property override.
I include the following for Items and get an AttributeError tuple_of_items(emailscripts,'DTML Method') In this case, "context" is the Formulator item, which is not a folder...
Look careful at your error message! It should tell you, what attribute is not found.
My assumption is - emailscripts is an object If it is indeed, then you must not use subscription nor "getattr". Use the object directly (at least, if it is the correct one).
- and DTML Method is a string That should not be a problem.
Viele Grüße Dieter
participants (3)
-
Dieter Maurer -
Dieter.Maurer@Haufe.de -
Trevor Toenjes