How do I use getattr in web2py

23 views
Skip to first unread message

Maurice Waka

unread,
Jun 14, 2014, 5:51:38 AM6/14/14
to web...@googlegroups.com

My code:

from applications.Folders1.modules.myfolder1.main import main
from applications.Folders1.modules.myfolder1.list1 import GAMES0
code.....
name3 = main()  
class Filters(object):

    def Filter_cause(self):                            
            for item in name3.split():
                b = False
                for c in FILTERTYPE:
                    b = b | (item.find(c) != -1)
                if b:
                    for (func) in GAMES0:
                        func()
    def Filter_cause(self):
             code....
                        func()
o = Filters()
for stuff in dir(o):                    
    if 'Filter' in stuff:
        getattr(o, stuff)()

in the controller:

import Filters
def view_post():
    code...
    data = Filters()
    form = code
return locals()

in the HTML view

{{extend 'layout HTML'}} {{= data}}

I want the func() to help display data on the view HTML When I run this in the controller, i get an error: communication error when I run in the controller as:

data = Filters.getattr(o, stuff)()# obviously i may be wrong on code here

The local host goes very slow What should I do? N/B still new in Python and web2py

Reply all
Reply to author
Forward
0 new messages