Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 15th, 2008, 07:56 PM
Noodles23's Avatar
Noodles23 Noodles23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Auckland, NZ
Posts: 421 Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 2 Days 22 h 5 m 2 sec
Reputation Power: 386
Problem running a python script

I'm a newbie at python, but I'm trying to run this script: http://www.mnot.net/cacheability/

I've got it setup as a cgi script and it executes, but I get this error:

Code:
Traceback (most recent call last):
  File "/var/www/apache2-default/cgi-bin/cacheability.py", line 902, in cgi_wrap
    cgi_main()
  File "/var/www/apache2-default/cgi-bin/cacheability.py", line 871, in cgi_main
    print "

      ", f, "

"
  File "/var/www/apache2-default/cgi-bin/cacheability.py", line 111, in __repr__
    p(" %s\n" % (
  File "/var/www/apache2-default/cgi-bin/httpheadertypes.py", line 280, in __getattr__
    return self.__dict__[attr]
KeyError: '__str__'


Does this mean anything to anyone? Is there a way I can trace this error and fix it?

TIA
__________________
Wireless Forums

Reply With Quote
  #2  
Old April 16th, 2008, 04:51 PM
c-2501 c-2501 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Location: Scotland
Posts: 28 c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 22 m 21 sec
Reputation Power: 0
This seems to be caused by the scripts __getattr__ method attempting to return a value from the objects attribute dictionary that doesnt exist (the problem is __getattr__ is only called if the value doesnt exist in __dict__ in the first place, so why who ever wrote this thought that was a good idea is beyond me )

anyway someone already posted the solution to this on the python mailing list, what you need to do is access the file httpheadertypes.py and find the Dict.__getattr__ method override and replace it with the following

Python Code:
Original - Python Code
  1.     def __getattr__(self, attr):
  2.         if attr.startswith('__') and attr.endswith('__'):
  3.             raise AttributeError(attr)
  4.         attr = lower(replace(attr, '_', '-'))
  5.         return self.data[attr]


I've given this a quick test(far from extensive) and it seems to work now.

Hope this helps.

You can find the original mailing list entry about this problem here:

http://starship.python.net/pipermai...005/000484.html
Comments on this post
Noodles23 agrees!

Last edited by c-2501 : April 16th, 2008 at 05:02 PM. Reason: found better version of method edit

Reply With Quote
  #3  
Old April 16th, 2008, 05:29 PM
Noodles23's Avatar
Noodles23 Noodles23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Auckland, NZ
Posts: 421 Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)Noodles23 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2Folding Points: 684582 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 2 Days 22 h 5 m 2 sec
Reputation Power: 386
Thank you so much, I searched everywhere for a solution to this problem. Not knowing python made it a bit harder to sort out.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Problem running a python script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway