The problem is this would break for an that is bytecode compiled and does not come with source.
On Jun 18, 8:40 pm, "mr.freeze" <nat...@freezable.com> wrote: > Here's a variation that creates menus for all controllers and their > functions (except appadmin): > > import os > from gluon.myregex import regex_expose > ctldir = os.path.join(request.folder,"controllers") > ctls=os.listdir(ctldir) > if 'appadmin.py' in ctls: ctls.remove('appadmin.py') > response.menu = [] > for ctl in ctls: > filename = os.path.join(ctldir,ctl) > data = open(filename, 'r').read() > functions = regex_expose.findall(data) > ctl = ctl[:-3] > response.menu.append([ctl, False, '#', > [[f, False,URL(request.application,ctl,f)] for f in > functions]]) > > On Jun 18, 12:32 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > lol. If I could I would include it in menu.py. This is a good idea and > > I will think about including it. > > > On Jun 17, 9:51 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > > Thought I would share this piece of code I use during development to > > > automatically build response.menu in menu.py. It makes it easy to > > > navigate your site while testing. Massimo could probably rewrite this > > > in two lines :) > > > > import os > > > from gluon.admin import apath > > > from gluon.myregex import regex_expose > > > filename = os.path.join > > > (request.folder,"controllers" ,request.controller + ".py") > > > path = apath(filename, r=request) > > > data = open(path, 'r').read() > > > functions = regex_expose.findall(data) > > > > response.menu = [ > > > [f.replace("_"," "), False, > > > URL(request.application,request.controller,f), []] for f in > > > functions > > > ] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~----------~----~----~----~------~----~------~--~---