[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
I just noticed when I try and use that class inside my search function (in controllers/default.py) it works fine. So it must be something to do with importing and using it? On Aug 23, 3:50 am, Bruno Rocha wrote: > This should work > > http://pastie.org/2412537

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
I get the same error? :( On Aug 23, 3:50 am, Bruno Rocha wrote: > This should work > > http://pastie.org/2412537

Re: [web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Bruno Rocha
This should work http://pastie.org/2412537

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Anthony
I'm not sure why you're getting that specific error, but I see a few problems: This may be a typo, but your module pastie says the module is named object.py (which is probably not a good idea, since 'object' is a Python builtin), but the controller says 'from objects import Search' (note the

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
Module: http://pastie.org/2411032 Controller: http://pastie.org/2411038 View: http://pastie.org/2411047 That should be everything, thanks for the help man, I really appreciate it! :) On Aug 22, 9:27 pm, Bruno Rocha wrote: > share your whole code in some pastie, gist or send the .py files I wil

Re: [web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Bruno Rocha
share your whole code in some pastie, gist or send the .py files I will take a look and try it here.

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
Yep just tried it then, same error unfortunately :( On Aug 22, 8:15 pm, Bruno Rocha wrote: > did you imported in this way: > > from objects import Search > > return dict(search=Search.show(db)) > > ???

Re: [web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Bruno Rocha
did you imported in this way: from objects import Search return dict(search=Search.show(db)) ???

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
:( making an instance or adding @staticmethod won't work either, why is it returning the error saying it has no attribute 'show'? why is it looking for an attribute shouldn't it be saying it has no function at least? On Aug 22, 6:38 pm, Bruno Rocha wrote: > ok small corretion, you need it as stat

Re: [web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Bruno Rocha
ok small corretion, you need it as staticmethod (or need a instance before calling) change to: class Search(object): @*staticmethod* def show(db): *Explanations about imports:* from gluon impot * The above is to have access to web2py helpers and other gluon modules, if you d

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
I've run into a problem, why won't this work: # controllers/default.py def search(): return dict(showsearch=objects.Search.show(db)) # controllers/default.py # modules/objects.py from gluon import * request = current.request class Search(object): def show(self, db): search = db(d

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
1 more thing, could you explain these lines please: from gluon import * request = current.request On Aug 22, 4:46 pm, Bruno Rocha wrote: > I guess it is not wrong, but I do not recommend too much code in > controllers, controllers should be for decide the app flow. > > I reccomend you to create

[web2py] Re: Nesting functions inside functions in controllers

2011-08-22 Thread Jarrod Cugley
Great advice, I'll do that :) Thanks, Bruno! On Aug 22, 4:46 pm, Bruno Rocha wrote: > I guess it is not wrong, but I do not recommend too much code in > controllers, controllers should be for decide the app flow. > > I reccomend you to create a module in /modules > > # modules/myobjects.py > fro