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:
  #1  
Old November 17th, 2004, 01:58 PM
mirizarry mirizarry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 mirizarry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mod_python throws 'mp_request' object has no attribute error. Why?

I have an app that runs fine under python 2.3.4. When I run it under mod_python I get the following:


Mod_python error: "PythonHandler dispatcher"

Traceback (most recent call last):

File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
result = object(req)

File "/var/www/python/dispatcher.py", line 49, in handler
return handlerfunc(req)

File "/var/www/python/conversionList.py", line 22, in handler
ConversionList(req, 'conversionList.pdf', 2005)

File "/var/www/python/conversionList.py", line 47, in __init__
self.createReport(req, self, args, year)

AttributeError: 'mp_request' object has no attribute 'createReport'


What could I be missing or have not done correctly? Here is the code in question:

Code:
from mod_python import apache
from reportlab.pdfgen import canvas
import time, os, sys

from optik import OptionParser
import MySQLdb
import MySQLdb.cursors

try:
    import _rl_accel
        ACCEL = 1
    except ImportError:
        ACCEL = 0

from reportlab.lib.units import inch, cm
from reportlab.lib.pagesizes import LETTER

def handler(req):
    req.content_type = "text/html"
    if req.header_only:
        return apache.OK
    ConversionList(req, 'conversionList.pdf', 2005)
    return apache.OK

class ConversionList:
    top_margin = LETTER[1]
    bottom_margin = inch
    left_margin = inch/2
    right_margin = LETTER[0] - inch
    frame_width = right_margin - left_margin
    newPageFlag = 0
    HeaderNeeded = 0
    PageHeader = 1
    CurrentGroup = ''
    row = ''
    GREENBAR = (14.875*inch, 11*inch)
    BILLING = (9.7*inch, 5.5*inch)

    def __init__(req, self, args, year):
        self.createReport(req, self, args, year)

    def createReport(req, self, args, year):
        started = time.time()
        self.a = time
        self.b = self.a.localtime()


Thanks,
Mel

Reply With Quote
  #2  
Old November 17th, 2004, 05:35 PM
mirizarry mirizarry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 mirizarry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Fixed the problem on my own.

Changed it to keep the __init__ function from calling createReport. It now looks like this:

Code:
def handler(req):
    req.content_type = "text/html"
    if req.header_only:
        return apache.OK
    a = ConversionList(req)
    a.test(req, 'conversionList.pdf', 2005)
    return apache.OK

class ConversionList:

    def __init__(self, req):
	self.top_margin = LETTER[1]
	self.bottom_margin = inch
	self.left_margin = inch/2
	self.right_margin = LETTER[0] - inch
	self.frame_width = self.right_margin - self.left_margin
	self.newPageFlag = 0
	self.HeaderNeeded = 0
	self.PageHeader = 1
	self.CurrentGroup = ''
	self.row = ''
	self.GREENBAR = (14.875*inch, 11*inch)
	self.BILLING = (9.7*inch, 5.5*inch)

    def test(self, req, args, year):
        req.write("Made it!")
        self.createReport(req, args, year)

    def createReport(self, req, args, year):
        started = time.time()
        self.a = time


Mel

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > mod_python throws 'mp_request' object has no attribute error. Why?


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT