473,549 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange error with getattr() function

Hi There!

I'm trying to use Zope and the product OpenFlow.

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 "WorkFlowTe st"
openflow_id=con tainer.aq_paren t.id

if (hasattr(contai ner,openflow_id ):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getatt r(container,ope nflow_id)

At this point, I got the error: attribute name must be string

The *strange* is that I get the same error even if I pass the attribute
name to the getattr() function as pure string:

getattr(contain er,"WorkFlowTes t")

(sic!!!!!)

I'm a lot confused!
Thanks in advance.

--
H0le

Dec 18 '06 #1
4 2401

Hole ha scritto:
Hi There!

I'm trying to use Zope and the product OpenFlow.

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 "WorkFlowTe st"
openflow_id=con tainer.aq_paren t.id

if (hasattr(contai ner,openflow_id ):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getatt r(container,ope nflow_id)

At this point, I got the error: attribute name must be string
I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??

Dec 18 '06 #2
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 "WorkFlowTe st"
openflow_id=co ntainer.aq_pare nt.id
Are you sure it's a string? Some objects have an id() method. You
always should use getId().
>if (hasattr(contai ner,openflow_id ):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getatt r(container,ope nflow_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(contai ner,"WorkFlowTe st")
(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

Dec 18 '06 #3
At Monday 18/12/2006 13:25, Hole wrote:
At this point, I got the error: attribute name must be string

I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??
(Which Zope version?)
If you don't catch the exception, an error page will be displayed,
pointing to the error_log object.
--
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

Dec 18 '06 #4

Gabriel Genellina ha scritto:
At Monday 18/12/2006 13:25, Hole wrote:
At this point, I got the error: attribute name must be string
I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??

(Which Zope version?)
If you don't catch the exception, an error page will be displayed,
pointing to the error_log object.

Hi Gabriel,

thanks a lot for your replies.

I've resolved the problem catching the exception and printing the
traceback in a file.

The problem was, indeed, in a getattr() call performed in another
function, to which I passed an int rather than a string.

Bye!

--
DN

Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6075
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line #80 and line # 38 are the first line offenders. --> --> -->
3
2062
by: Johnny | last post by:
Hi, I wonder what is the difference between the built-in function getattr() and the normal call of a function of a class. Here is the details: getattr( object, name) Return the value of the named attributed of object. name must be a string. If the string is the name of one of the object's attributes,
19
4618
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using FileSearch in win98 to fill an array with filenames with no problems since about 1998. From the 97 Help: (The Filename Property of the FileSearch object)...
3
3066
numberwhun
by: numberwhun | last post by:
Hello everyone! I am presently going through the "Dive Into Python" tutorial which I obtained from their website. No, this is not for any class, I am self-learning the Python language. I am in Chapter 4 and reading about "Getting Object References with getattr". First, it say in there that, "you can get a reference to a function without...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7965
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7483
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6051
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.