On Friday, October 7, 2016 at 11:29:36 PM UTC-4, Joe Barnhart wrote: > > I created some "widgets" (for lack of a more descriptive name) using the > same pattern as the Auth object. When you call it, it returns a special > function that can respond to several different "sub-functions". This has > been tremendously handy but now I'm encountering a problem -- when I uses > this in my "default" controller it fails to parse its sub-function properly. > > Here is the code, patterned after Auth: > > def __call__(self): > from gluon.http import HTTP > request = current.request > ra = request.args > if not ra: > return self.widget() > if ra[0] in self.api: > return getattr(self, ra.pop(0))() > else: > raise HTTP(404) > > The above code lives in a module, not a controller. The method > self.widget() just returns a dictionary that contains the html and so > forth, for building the presentation of the widget. The instance var > self.api contains a list of "sub-functions" that, when called, will > return something different than the widget() function. Usually this is > some sort of ajax function or other script-y thing that is called from the > widget. > > My problem lies in the request.args[]. When called from any controller > but my default, everything works perfectly. The calling URL looks > something like: > > /big_app/default/widget/sub_function/whatever >
How are you generating that URL? With the router, presumably it should just be /widget/sub_function/whatever, no? Also, what do you mean that it fails to work? Exactly what happens? We may need to see more code. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

