Python 2.7
Yet another new style class question... but not.
I have read the other questions and I seem to be getting the opposite result, but that is probably my ignorance.
class t1(object):
pass
c1 = t1()
print type(c1) # <class '__main__.t1'> within web2py <class '__restricted__.t1>
class t2():
pass
c2 = t2()
print type(c2) # <type 'instance'>
ok. great I don't have to pass 'object' to get new style classes (or have I missed something). So when I subclass something which should be a new style class (ie has 'object' passed in declaration) I am getting a class object which I can't fix by passing 'object' in my class declaration.
now to my specific situation: I am subclassing FPDF which is declared class FPDF(object) and trying to use the super function in my declaration.
class MyFPDF(FPDF):
def __init__(self, data):
super(MyFPDF, self).__init__()
self.res = data['res'] # reseller info
self.cust = data['customer'] # customer info
super(MyFPDF, self).__init__()
TypeError: super() argument 1 must be type, not function
I can't find a reference to this specific error anywhere.
Update
# -*- coding: utf-8 -*-
from fpdf import FPDF, HTMLMixin
import datetime
import os
import codecs
import PIL
@auth.requires_login()
class MyFPDF(FPDF, HTMLMixin):
# cutoff to start the next page. Not using auto page break.
cutoff = 275
footerLineheight = 3
footerFontSize = 6.5
footerTextColor = 128
def __init__(self, data):
super(MyFPDF, self).__init__()
self.res = data['res'] # reseller info
self.cust = data['customer'] # customer info
def pdfDoc():
data = _select_offer(offerId) # data.offer data.customer
data['res'] = db.reseller[data.offer.reseller_id] # data.res
pdf = MyFPDF(data)
pdf.add_page() # from here is the code for the pdf document
The only reason I am overriding init() is so I can pass in the address information for the footer. I can't pass it directly to my footer method because the method is used internally in the module. So adding an argument causes other problems.
I have just worked it out. The problem is the unnecessary decorator @auth.requires_login() on the class declaration.