#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    3
    Rep Power
    0

    Class error with mod_python.


    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:

    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):
    #req.createReport()
    self.createReport(req, self, args, year)
    #self.test()

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

    .......


    Thanks,
    Mel
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Please read the stickies and repost.

IMN logo majestic logo threadwatch logo seochat tools logo