http://web2py.com/AlterEgo/default/show/246

Will hopefully be added to main Geraldo docs too:
https://sourceforge.net/tracker/?func=detail&aid=2830566&group_id=251460&atid=1126588

This is all working great for me with simple reports, however I am
currently unable to get SubReports to work....has anyone else got this
working?

Within Django this is done as:
queryset_string = '%(object)s.purchaseitem_set.all()'

I am trying to replicate this using something like:
queryset_string = 'db(db.purchaseitem.purchase==%(object)s.id).select
()'

but the class can't see 'db'
I therefore extended the Report class (from
http://github.com/marinho/geraldo/blob/7951ad4c2f984b9c8aff3ad67537d6da22a3ba70/geraldo/base.py)
to pass this in:
class MyReport(Report):
        def __init__(self, queryset=None, db=None):
            " Initialise parent class & make any necessary
modifications "
            Report.__init__(self, queryset)
            self.db = db

report = MyReport(queryset=purchases, db=db)

But I can't see how to pass from here into the SubReport.

queryset_string = 'self.db(self.db.purchaseitem.purchase==%(object)
s.id).select()'
fails as:
NameError: name 'self' is not defined

This seems to be because the class isn't instantiated at this point.

I tried extending the child class:
class MySubReport(SubReport):
        def __init__(self, db=None, **kwargs):
            " Initialise parent class & make any necessary
modifications "
            SubReport.__init__(self, **kwargs)
            self.db = db

But I get the same issue since can't pass 'db' across as not
instantiated...

Full code here (look at kit_export_pdf()):
http://trac.sahanapy.org/browser/controllers/budget.py

Suggestions welcomed :)

F
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to