Strange error with getattr() function
Gabriel Genellina
gagsl-py at yahoo.com.ar
Mon Dec 18 13:36:49 EST 2006
At Monday 18/12/2006 12:33, Hole wrote:
>I'm trying to use Zope and the product OpenFlow.
Try posting in the Zope list, you surely will have more responses.
>I got the following error while I was using the built-in function
>getattr() to retrieve an OpenFlow object:
>
>attribute name must be string
>
>
>Actually, I surely pass a string as attribute name to getattr()
>
>The code:
>
>#following instruction returns me the string "WorkFlowTest"
>openflow_id=container.aq_parent.id
Are you sure it's a string? Some objects have an id() method. You
always should use getId().
>if (hasattr(container,openflow_id):
> #the interpreter enter in this block, so
> #it's sure that container has an attribute called WorkFlowTest
> openflow=getattr(container,openflow_id)
>
>At this point, I got the error: attribute name must be string
getattr is acquisition-aware so you might be retrieving another thing...
>The *strange* is that I get the same error even if I pass the attribute
>name to the getattr() function as pure string:
>
>getattr(container,"WorkFlowTest")
>(sic!!!!!)
If you're really sure of this, I think the error may occur inside
another function in the getattr chain.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list